Wednesday, June 10, 2009

Backup - Part I

"If there's one thing people know they should do, it's backup their data.
If there's one thing people don't do, it's backup their data."

-Jim Fraser


For me, I resisted making backups for a long time because as a former Windows user, I was scarred by how hard it was. In Windows, your data is all over the place (and not in just one directory), backing up Windows itself is just about impossible, most backed up programs won't run after being restored, and there's no easy, integrated way to make backups.

Proprietary software tends to save your files in volumes, so that you have no access, without the software, to the individual files that comprise the backup. If you lose the install disk, your backup is garbage.

Linux makes backing up data so unbelievably easy though, it's almost stupid not to.

Rsync is the tool and it makes perfect copies between filesystems. It is incremental, so the first backup will take awhile, but each one after will only backup the changes. The command to use is:

rsync -a SOURCE DESTINATION


The "-a" switch puts rsync into archive mode, which activates a number of other switches that are useful for performing backups (such as recursing into subdirectories, for example).

Other switches to consider are:

"-x" keeps rsync from crossing filesystem boundaries. This is useful if you're doing a backup of / and you have /home on a different partition and you don't want the other partition included in the backup.

"-H" preserves hard links. The man page says that this is computationally expensive, but in my experience, it has never been a problem. Hard links occur when two files both point to the same location on the disk and they very rarely occur in personal files. If "-H" is not used, then the backup will have two separate files with two copies of the data, instead of two files pointing to the same data. I generally turn this on when I'm backing up / and leave it off when I'm backing up /home.

"-v" is for verbose mode and results in a listing of all the files that are backed up.

"-z" turns on compression of the data stream. This does not compress the backed up data. Generally, I only turn this on if I'm backing up data across a slow connection, such as across the Internet.

"--delete" deletes files at the destination if they don't exist at the source. Turn this on if you want a one-to-one copy of your data.

No comments:

Post a Comment