I run applications such as Nextcloud or WordPress in Docker and want to automate reliable backups with borgmatic. My plan is to back up both the application files or mounted volumes and the database. For the database, is mysqldump --single-transaction sufficient for a nightly backup, or should I enable maintenance mode so file changes and database contents are guaranteed to match? I'm especially wondering whether a short backup window around 3 AM is adequate, and what backup and restore setups others use.
3 Answers
Another option is to back up the host or virtual machine with a snapshot-based system, while also copying important data to a separate location. Tools such as rclone or Syncthing can provide an additional copy, but they shouldn’t replace database-aware exports. Keep at least one backup independent of the running server and regularly verify that you can restore the application, volumes, and database together.
A single-transaction dump gives you a consistent view of the database, but it doesn’t coordinate that snapshot with files being uploaded or modified at the same time. For the strongest consistency, briefly enable maintenance mode, dump the database, and capture the application files or volumes during that window. The window can be very short for a small installation, but it’s still important to perform an actual restore test—successful backup commands alone don’t prove the backup is usable.
Back up both parts separately: export the database with a transactional dump and back up the persistent Docker volumes or bind-mounted data. A nightly low-traffic schedule reduces the chance of changes during the process, but it doesn’t guarantee consistency. If losing a small number of simultaneous changes is acceptable, you may skip maintenance mode; otherwise, use a brief maintenance window or filesystem snapshot.

That makes sense. I was hoping a low-traffic 3 AM backup would eliminate the need for maintenance mode, but matching the database and files is the main concern.