~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Use block storage for your application data

Published on

Updated on

2 minute reading time

One day I was upgrading my server from Fedora 37 to 38 and the thought came to my head.

What if this installation fails and I need to recreate the server?

Luckily that didn’t come to pass, but the thought was enough to scare me into learning Ansible.

Honestly, I’ve been skeptical of it for a while. I thought that having bash automation scripts was good enough and that Ansible will come and go.

Except, that it’s been around for the last 11 years…

Consider me converted! My favorite module is lineinfile. It’s all too common in Linux for setup instructions to contain “edit x line in y file.”

Now, I have Playbooks written for configuring my server, but what about the data?

I was chatting with my good friend Stefano Coronado and he suggested using block volumes. Most VPS providers offer this feature and its persistent data storage that can be attached to one or more servers within the same data center.

This of course does not substitute having good backups, but having separation between configuration and data is a great idea.

Lets say that I have block storage mounted on /mnt/storage.

It’s easy to point directly to it within docker-compose:

database:
  image: docker.io/mongo:5.0
  volumes:
    - /mnt/storage/database/data/db:/data/db

If you’re using an application outside of docker and is not easily configurable, we can make use of symlinks.

For example, if an application is expecting configuration to be at /etc/special then:

sudo ln -s /mnt/storage/special /etc/special

sets up a symlink at /etc/special to point at /mnt/storage/special.

Learn more on how to specifically setup and mount a block volume depending on your hosting provider:

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :