What's the Best Way to Backup Multiple Docker Compose Files?
Asked by
cupboard_inventory
I've got all my services running in Docker containers, each in its own directory on my filesystem. For example, Immich is located at `/home/me/Docker/Immich/`, which contains the relevant docker-compose and .env files, along with data stored as bind mounts. I'm in the process of migrating to a new VPS provider since my current one is going out of business. I've explored various backup options like Offen, but they tend to work best with single large compose files. I could just tar up the whole Docker directory, but I also have some volumes that aren't bind mounts and need to make sure those are included in the backup. I'm comfortable using the command line, so I'm looking for the best practices for backing up and restoring my setup. Any advice?
Answers
Have you tried using Codex for generating backup scripts? It could simplify the process for you! Just set it up to handle backups, and it can take care of the rest.
Reply to this answer
I wouldn't recommend running Docker on a VPS without a backup strategy. For your case, Duplicati could work wonders. It allows you to back up your entire stack folder (including your `docker-compose.yaml` and `.env` files) along with your data folder. Plus, you can set it to stop Docker before the backup and restart it afterward, making it seamless.
Reply to this answer
For managing your compose files and .envs, using Git is a solid option. You can track changes and roll back if needed. For securing secret .env files, try Sops. As for data directories, Iโd recommend using SCP since it leverages SSH for transfers. It's reliable and straightforward.
cupboard_inventory: I get that Git is great, but I've had some pretty unfortunate experiences with it. I guess Iโm a bit of a 'gitiot' if Iโm being honest!
Reply to this answer
Add your answer
Answers are reviewed before publication.
cupboard_inventory: Thanks for the suggestion! What exactly is Codex? Any specific site I should check out for details?