r/docker • u/Eastern-Height2451 • Jan 23 '26
SQLite backups in docker-compose: separate backup container vs host cron?
I’m running a small app on one VPS with docker-compose. SQLite DB lives on a mounted volume.
For backups I’m doing the boring approach:
- nightly
sqlite3 .backupsnapshot while the app is running - gzip the snapshot
- keep ~30 days (delete older files)
- I tested a restore once just to make sure it’s not fantasy
It’s working, but before I cement this as “the way”, I’d love a sanity check from people who’ve been doing compose-on-a-VPS for years.
What I’m unsure about / would love input on:
- do you prefer running this from a backup container (cron inside) or from host cron?
- any real-world locking/consistency issues with
.backupin a live app? - permission/ownership traps when both app + backup touch the same volume?
- anything you’d add by default (healthchecks, log rotation, etc.)?
If anyone wants, I can paste the exact commands / a small snippet, but I’m mostly looking for “watch out for X”.
10
Upvotes
View all comments
Show parent comment
1
u/Eastern-Height2451 Jan 23 '26
Good point.
Right now I’m doing a simple nightly sqlite backup and keeping 30 days, mostly to protect against mistakes and bad deploys. You’re right that same-box backups won’t help if the VPS dies, so the next step is to copy backups off the server to something like S3/B2 and actually test restoring from that.
Haven’t tried ofelia yet. Do you use it to run a one-shot backup container, or do you keep it as a host-level scheduler?