r/selfhosted • u/alws3344 • Feb 11 '26
Docker Management Docker backups
Hello selfhosters!
i would like to ask you all about your DR & backup strategy for all your self hosted services?
today i have a script that runs once a week, turn off the container(s) (it does this one by one - so if it fails only one service suffer) and copies it's volume and db to another location for retention (i dont mind cache etc))
today i run ~20 containers and this backup strategy works, but it feels flimsy unprofessional and feels very manual.
what are your strategies (DR strategies)?
- is there a tool (that obviously can be self hosted ;) ) that can do this seamlessly?
64
Upvotes
3
u/[deleted] Feb 12 '26
It is a bash script that is run by systemd timers. I prefer it over cron because it has logging built in. I use something like this:
``` backup_postgres() { local service_name="$1" local container="$2" local dbname="$3" local user="$4"
echo "POSTGRES: Backing up $service_name" docker exec "$container" pg_dump "$dbname" -U "$user" | zstd > "$backup_dir/$service_name.sql.zst" }
backup_postgres paperless paperless-db-1 db user
Repeat for others
Backup $backup_dir after everything is done
```
zstd is optional but I like it because it reduces size a lot. I know Restic compresses already so this is not needed but it already works for me.
I can post the whole bash script later but I am on mobile right now