I’ve searched this long and hard and I haven’t really seen a good consensus that made sense. The SEO is really slowing me on this one, stuff like “restic backup database” gets me garbage.
I’ve got databases in docker containers in LXC containers, but that shouldn’t matter (I think).
me-me about containers in containers
I’ve seen:
- Just backup the databases like everything else, they’re “transactional” so it’s cool
- Some extra docker image to load in with everything else that shuts down the databases in docker so they can be backed up
- Shut down all database containers while the backup happens
- A long ass backup script that shuts down containers, backs them up, and then moves to the next in the script
- Some mythical mentions of “database should have a command to do a live snapshot, git gud”
None seem turnkey except for the first, but since so many other options exist I have a feeling the first option isn’t something you can rest easy with.
I’d like to minimize backup down times obviously, like what if the backup for whatever reason takes a long time? I’d denial of service myself trying to backup my service.
I’d also like to avoid a “long ass backup script” cause autorestic/borgmatic seem so nice to use. I could, but I’d be sad.
So, what do y’all do to backup docker databases with backup programs like Borg/Restic?
I guess I’m a dummy, because I never even thought about this. Maybe I got lucky, but when I did restore from a backup, I didn’t have any issues. My containerized services came right back up like nothing was wrong. Though that may have been right before I successfully hosted my own (now defunct) Lemmy instance. I can’t remember, but I think I only had sqlite databases in my services at the time.
Good to know if I need to just throw the running database into borg/restic there’s a chance it’ll come out ok! Def not a dummy, I only found out databases may not like being backed up while running through someone mentioning it offhandedly