How are you guys backing up your self hosted services running via docker?
I backup my compose files and docker bind mounts using restic. https://restic.net/
This allows me to backup to s3, to onedrive and to a local repo. I have this scheduled using ansible and cron.
In running my applications in Docker most of them are using SQLite database with some additional asset directories in some cases.
I’ve written a custom shell script that takes database backups for each service and makes a copy of asset directories. It then compiles them in a single tarball and uses rclone to upload to Backblaze.
This script runs as a cronjob. This has been relatively stable solution for me.
I have 4 form factor PCs. Almost all my services are running with docker-compose. I have installed the following on every machine:
- borg backup (repos initialized with seperate key files)
- borgmatic (for setting up borg easily)
- rclone (onedrive activated as a remote)
Everynight a cron job runs on each machine and creates backup of /home/ folder, attached extertnal drives (if there are) and dumps mysql databases.
- local borg repo stays in the PC
- All PCs have a remote repo on an external drive attached to one of the PCs which I am using as NAS.
- As last step, borgmatic sends the repos to onedrive using rclone
I run kopia and backup the bind mounts on each of my docker systems.
i also run a script to backup my running containers to docker-compose yaml files.
i backup everything on my server to 1 folder on the same box and run kopia to backup that folder from my server to a nextcloud instance on another server in another location (i also control this nextcloud instance)
(the backup on my server is just copying/compressing files using scripts i have written)
I’m a big fan of restic, and choosing multiple destinations for your backup targets is critical for redundancy (while snapshots will help against corruption or ransomware)
No matter how you choose to backup, ESPECIALLY since it’s so easy with Docker, consider restoring to a different machine and try bringing up your entire docker stack again (I assume you’re already using compose, portainer or whatever). It should just work. And take all of an hour to smoke test and confirm your backups will do the job.
Second this. You should ALWAYS test your backups, otherwise it’s as good as having no backup in the first place.
Most of my docker containers have some kind of db connection, so I dump the db to file and back that up together with any media/assets with rsnapshot running on a daily basis to a 2nd node.
I’m using Borgmatic to backup my homelab to a storage server at Hetzner. I have a bunch of other servers, which don’t really require backups and is easily redeployed via docker with static files.
How do you like kopia? I looked at a while ago and have the opportunity to pivot my backup solution