Disk drives fail. Backups are really important to have. Fingers delete or edit the wrong files. Backups are good then too. For my backups I use a nice big usb disk drive, rsync, and a daily cron job.

The rsync-backup script runs the backup using an rsync command and the rsync-exclude perl script to tell rsync which directories to exclude from the backup.

Note that these scripts are mostly pretty customized for my system, but can serve as examples of how to do backups that you can modify for your own system.

One of the nifty features of rsync I use is the --backup-dir option. I make a separate directory each time I run backup and rsync moves changed files from the latest directory (which always mirrors the most recently backed up contents of my disk) into the per-backup cb-yyyy-mm-dd-hh-mm-ss directory, so all the recent changes hang around in multiple incarnations where I can dig them up if I want to go back in time to an earlier version of a file.

Naturally, this will eventually fill up the usb drive, but I manually remove the old backup directories when the disk starts getting full. Usually there is plenty of room to keep a month or two worth of backups.

I run the backup script every day by simply making a symlink in the /etc/cron.daily/ directory pointing to the backup script.

The rsync-exclude perl script is where most of the customization lives. It "just knows" how my various disk partitions are arranged, which files I want to backup, etc. In particular, there are several versions of linux on this box, and I back up all of them (or all the useful ones anyway), by backing up the root trees from the places where I have them mounted and excluding the same subdirectories in those roots that I exclude from the current system's root.

Since backups are kind of important, it is also important not to have them corrupted or deleted if you can help it. One thing that can help is the Hide Disks web page which explains how to keep hal from automatically mounting the usb drive any time anyone logs in.

Page last modified Fri Feb 27 22:33:31 2009