For a Docker-based Nextcloud or WordPress setup, I'm planning to use borgmatic and back up both the application files/volumes and the database. For an automated nightly backup, is a command such as `mysqldump --single-transaction` enough without enabling maintenance mode, or should I briefly put the application into maintenance mode so the database dump and file backup represent the same point in time? I'd also like to know what backup and restore process others use.
3 Answers
Back up both pieces separately: export the database with a transactional dump and preserve the persistent Docker volumes containing uploads, configuration, and application data. If you can take a filesystem or VM snapshot, that makes it easier to capture the files and database at nearly the same point in time. Keep multiple generations and verify that you can rebuild the containers and restore from scratch.
For smaller installations, backing up the persistent volumes and database dumps to separate storage is usually sufficient. Some people handle this at the host or VM level instead, using scheduled VM backups and a separate sync tool for important user data. Whichever method you choose, don’t rely on volume copies alone—make sure the database is exported properly and perform occasional recovery tests.
`--single-transaction` gives you a consistent snapshot of the database itself, but it doesn’t coordinate with files that are being uploaded or modified at the same time. The safest approach is a short maintenance window: pause changes, dump the database, back up or snapshot the application volumes, then bring everything back online. The most important part is regularly testing a full restore, since a backup job completing successfully doesn’t prove the backup is usable.

Would a low-traffic window around 3 AM be good enough without maintenance mode for Nextcloud or WordPress, or is the consistency risk still significant?