How can I back up Docker volumes safely without stopping containers?

0
0
Asked By MellowPine42 On

I'm running around 15 containers, including services such as Jellyfin, Paperless, and Vaultwarden, on Ubuntu 22.04 with an ext4 filesystem. I'd like to automate daily backups of all Docker volumes instead of manually listing and copying them.

I've considered volume-backup images, Restic or Borg with the volumes mounted, and simply backing up my Compose files along with the data directories. Ideally, the process would run without stopping services, but I'm unsure whether that provides reliable backups—especially for databases. What backup strategy or tools work well for this setup, and when is it necessary to stop or pause containers?

2 Answers

Answered By DataFern63 On

Whether live backups are safe depends on the application. Copying ordinary static files while containers run is usually fine, but copying an active database’s files is not the same as making a database backup. Use a database dump, checkpoint, or application-specific export for services that store frequently changing data. Otherwise, the backup may contain an inconsistent or corrupted database.

SilverOtter29 -

The important part is testing the restore. Bring the backup up as a separate set of containers and verify that the applications and databases actually work, rather than assuming a successful archive means the backup is usable.

Answered By CloudyBirch26 On

A practical setup is to use a scheduled job that creates database dumps, briefly stops only the services that need filesystem consistency, archives the relevant volumes, and then starts those services again. Store multiple generations off the host and periodically perform a full restore test. A backup that never gets restored is only a theory.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.