Atomic Rsync? cron’d backup of regularly changing directory to remote: insuring one complete backup

backuplinuxrsync

I've got a directory that changes regularly, but whose files are related. I want to rsync that to a remote location, insuring that I always have one complete set of files at the remote. That is, if I have one complete backup, I want that preserved until I have a second complete one, in order to insure that any network interruption does not destroy the integrity of the first. If you think about it, --backup doesn't work, because it won't be clear if a not-backed-up file is part of the first complete backup, or the second incomplete one.

While what I want to do is scriptable, I'm thinking there's got to be a canned solution somewhere. I gather rdiff-backup would do it, rolling back partial backups, but I can't get that installed on the target machine. Does anyone have any other leads?

Best Answer

If you work with opened files like a database, a direct rsync can be a bad idea, since rsync won’t read atomically all the blocks of all the files of the database. The most atomic way would need a system with snapshots enabled. This needs a dedicated lvm partition, or a file system like btrfs or zfs. When the partition is snapshoted, your rsync can work freely on a stable set of files. The --delay-updates may be used to make remote application more atomic.

Related Question