Hello Self-Hosters,
What is the best practice for backing up data from docker as a self-hoster looking for ease of maintenance and foolproof backups? (pick only one :D )
Assume directories with user data are mapped to a NAS share via NFS and backups are handled separately.
My bigger concern here is how do you handle all the other stuff that is stored locally on the server, like caches, databases, etc. The backup target will eventually be the NAS and then from there it’ll be double-backed up to externals.
-
Is it better to run
cp /var/lib/docker/volumes/* /backupLocation
every once in a while, or is it preferable to define mountpoints for everything inside of/home/user/Containers
and then use a script to sync it to wherever you keep backups? What pros and cons have you seen or experienced with these approaches? -
How do you test your backups? I’m thinking about digging up an old PC to use to test backups. I assume I can just edit the ip addresses in the docker compose, mount my NFS dirs, and failover to see if it runs.
-
I started documenting my system in my notes and making a checklist for what I need to backup and where it’s stored. Currently trying to figure out if I want to move some directories for consistency. Can I just do
docker-compose down
edit the mountpoints indocker-compose.yml
and rundocker-compose up
to get a working system?
I back up all the directories and docker-compose files using Restic (via Backrest) stored on Backblaze B2, and also the whole Docker LXC via Proxmox’s backup function to a local HDD.
There’s a chance some databases could be backed up in an unusable state, but I keep like 30-50 snapshots going back months, so I figure if the latest one has a bad DB backup, I could go back another day and try that one.
I also don’t really have irreplaceable data stored in DBs, stuff like Immich has data in a DB that would be annoying to lose, but the photos themselves are just on the filesystem.
For testing Restic I pull a backup and just go through and check some of the important files.
Proxmox backup is really easy to test, as it just restores the whole LXC with a new ID and IP that I can check.