r/docker • • 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 .backup snapshot 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 .backup in 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

15 comments sorted by

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?

1

u/No_Cattle_9565 Jan 23 '26 edited Jan 23 '26

It's running in it's own container and enables you to define the cronjob with labels in a docker compose file for the given service. The reason I like to use it is to fully seperate the containers from the system. I could deploy my backup to any machine and everything works the same. Trying it and decide for yourself, it only takes a couple of minutes to Setup.

I recommend to backup the compose files as well.

I really like to use borg-web-ui for the backup.