Tuesday, December 15, 2009

Easy Backups with rsync: Part 3 of 3

In this part we'll write a back up script and finish up.

Boot up off your USB flash drive. Now you need to figure out which drives you want to back up and what they are called in /dev. In puppy this is a piece of cake. An icon for each device is displayed at the bottom of the desktop. Clicking on the icon mounts the device as /mnt/<device name> and opens a file explorer on that drive. All you need to do is click through the devices until you find the ones you want.

Now you need to write the rsync script. Here is mine:

backup.sh
---------
rsync -rltDvP /mnt/sda1/Users/Henri/ /mnt/sde1/backups/windows/
rsync -rltDvP /mnt/sdc3/henri/ /mnt/sde1/backups/ubuntu/

I use this to backup the home directories on my Windows and Ubuntu partitions. Before I run this, I ensure that both sda1 and sdc3 are mounted and my backup drive is mounted at sde1.

Note that the trailing slashes on the paths are important. Otherwise the source folder will copied into the destination.

The switches were chosen to make a copy of the source directory recursively(-r), with symlinks copied as symlinks (-l) and modification times preserved(-t). The verbose messages (-v) and progress indicators (-P) are turned on. This is equivalent to the archive (-a) option but without preserving permissions, ownership and file groups. Because I'm backing up onto a NTFS drive, those options don't work correctly. (Ultimately I'll add the --delete flag to delete files in the destination not present in the source.)

Now save the script and you're ready. Once a week follow the steps given the Part 1 and your backups are sorted.

0 comments: