Home » Questions » Computers [ Ask a new question ]

Linux filesystem backup atomicity

Linux filesystem backup atomicity

On my Linux machine I'm using a home made backup script which is actually a few rsync calls. I've tested my restores and everything seems to be working, but are there any possible problems with this setup?

Asked by: Guest | Views: 149
Total answers/comments: 2
Guest [Entry]

"For an atomic backup you ideally need to stop all write access to the area being backup up which means stopping all services that might write to them.

If you use LVM then the snapshot facility makes this much less onerous as you only need to stop services for the length of time it takes to create the read-only snapshot which is almost instant. You take the backup from the snapshot and then remove it until a new one is needed for the next backup run. See http://tldpdotorg/HOWTO/LVM-HOWTO/snapshots_backup.html for more detail.

Don't leave the snapshot(s) active any longer than you need to though, as there are performance implications (though these are usually far less of a problem then having to have a full downtime period while the backups run)."
Guest [Entry]

"Yes, they can still be copied. Like suggested above I would dump the databases into a file, bzip them for good compression then rsync them to wherever

# mysqldump --all-databases -u user -p | bzip2 -c > mysqlbackup.sql.bz2
# <rsync stuff here>

Then to load it into the new database

# bzip2 -d mysqlbackup.sql.bz2
# mysql -u user -p < mysqlbackup.sql

To further ease any paranoia I sometimes revert to lsof -F | grep <keyword> to see if the file I want to transfer is actually in use, or open. If lsof returns null then I know I'm right to continue. You could use it to search for an open MySQL table as MySQL is writing to it. Once lsof returns null you can continue transferring files."