Time Machine for Unix
At Interlock Rochester we are searching for more things we can offer our members as membership benefits. One idea that came up was offsite backup using a standard USB hard drive that would be supplied by the member. I really like how Time Machine works for my onsite backups so I started searching for a way to replicate it’s functionality for an offsite backup (as TM only allows you to specify one backup set). I found this article by Michael Jakl that seems to do the job pretty well. Until we get server infrastructure implemented I’m using the following script to backup to the external hard drive that I’ll keep in my locker:
#!/bin/bash
rootvol=/Volumes/bdw-bk
destroot=/Volumes/DBBackup
img=/Volumes/bdw-bk/DBBackup.sparsebundle
src=$HOME
hdid attach $img
date=`date "+%Y-%m-%dT%H-%M-%S"`
mkdir -p $destroot/Backups
mkdir -p $destroot/Backups/current
mkdir -p $destroot/Backups/back-$date
echo Backing up $src to $destroot/Backups/back-$date using $destroot/Backups/current as link dest...
sleep 2
rsync -azvxP --delete-excluded --exclude-from=NOBAK.txt --link-dest=$destroot/Backups/current $src $destroot/Backups/back-$d$
rm -rf $destroot/Backups/current
ln -s back-$date $destroot/Backups/current
umount $destroot
umount $rootvol
bdw-bk is the volume name of my external hard drive. DBBackup is an encrypted sparse bundle disk image I created using Disk Utility. I’m currently only backing up my home directory. I’m hoping to improve this script, making it more reliable and flexible, so watch for updates. I’ll also eventually be adding “real” offsite support by making this all happen over SSH.

