Tiger + rsync

Sunday, October 28, 2007 10:22 PM

In preparation for Leopard I had to backup my data somewhere. So I decided to write a quick script for rsync'ing my home directory off to mounted volume. This script will shut off spotlight from indexing your system and backup volumes. Perform the rsync, then turn the indexing back on.

#!/bin/sh

BACKUP_SRC="/Users/<your home directory here>"
BACKUP_DEST="/Volumes/<your mounted volume name here>"
EXCLUDES="--exclude tmp* --exclude *Cache* --exclude .Trash*"
RSYNC_ARGS="-avzE --progress --delete $EXCLUDES "
RSYNC="/sw/bin/rsync $RSYNC_ARGS $BACKUP_SRC $BACKUP_DEST"

spotlight_switch()
{
    /usr/bin/mdutil -i $1 /
    /usr/bin/mdutil -i $1 $BACKUP_DEST
}

! test -d $BACKUP_DEST && echo "Please mount the backup drive!" && exit 

spotlight_switch off

echo $RSYNC
`echo $RSYNC`

spotlight_switch on