What's the Best Way to Back Up Live Database Files to a Ceph Cluster?

May 1, 2025 6 answers
Asked by amateur meteorologist
Hey everyone! I'm looking for some reliable methods to back up a live database directory from my local disk to a Ceph cluster. Unfortunately, we don't have the database running on the Ceph cluster currently due to network issues. I've tried mounting the Ceph volume and using `rsync` to copy files over, but I've run into a problem: `rsync` often fails because the files are being modified during the transfer. I'm considering two workarounds: using filesystem snapshots or making a local copy before syncing. Has anyone tried something similar, or do you have better suggestions for backing up in this scenario?

Answers

!~semaphore flags
What do you typically use for other backups? Canโ€™t those methods help with SQL-aware backups? Every SQL server generally offers tools to create dumps or backup files, so the simplest route would be to create an SQL dump and then copy that dump file over.
Reply to this answer
~+just passing through
I think the filesystem snapshot option is promising, especially since you'll be doing this multiple times. Each time, the diffs should be smaller. Just make sure to conduct a final shutdown of the database before you perform that last `rsync` for best results. Itโ€™s worth testing before you commit!
Reply to this answer
~!spelling bee
When backing up databases, it's usually best to utilize the built-in database commands like `mysqldump` or `mongodump` for the task. These commands ensure you're getting a usable file. If you really want to copy the files directly, remember to stop the database service first to avoid issues.
Reply to this answer
border-of-the-page
You really shouldn't rely solely on `rsync` for backing up database files, as you won't get a functional restore from that. It'd be safer to stick with the database's native tools like `pg_dump` or `mysqldump` and backup those output files using `rsync`. Better safe than sorry!
Reply to this answer
rna8.fold
You're spot on about avoiding `rsync` on live database files! A snapshot-based approach is definitely the way to go. Hereโ€™s how it looks: snapshot your `/data`, mount that snapshot, and then use `rsync` to copy it to Ceph. Don't forget to delete the snapshot afterward! If snapshots aren't an option, your `data-temp` method is a fallback, just know it uses more space and I/O. Also, check out tools like **BorgBackup** or **Restic** for incremental backups, as well as native DB dump tools like `pg_dump` or `mysqldump`. They're quite handy!
Reply to this answer
!SideQuest
If you can't use any backup tool that handles the database, snapshots might be your best bet for a consistent backup. Itโ€™s surprising if your database lacks means to generate a consistent backup. But honestly, always aim to use your database's native backup methods when possible!
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions