This evening I finished off my rsync script. It now uses the “—link-dir” feature to support proper incremental backups using hard links.

The system works pretty well; wander into the flat, wifi auto-connects and phone backs itself up automatically. No user intervention required whatsoever.

Here’s the finished rsynchero script:

#!/bin/bash

SRCDIR=$1 DESTDIR=$2

BDATE=`/bin/date ”+%Y-%m-%dT%H:%M:%S”`

/usr/bin/rsync -a \ —link-dest=$DESTDIR/current \ —force \ —ignore-errors \ —delete-excluded \ —delete \ —exclude ’**/dalvik-cache/**’ \ —exclude ’**/cache/**’ \ —exclude ‘/proc/**’ \ —exclude ‘/sys/**’ \ —exclude ‘/cache/**’ \ —exclude ‘/dev/**’ \ —exclude ‘/sdcard/newsrob/**’ \ -e ‘/usr/bin/ssh -p 2222’ \ $SRCDIR $DESTDIR/backup-$BDATE

if [ -d $DESTDIR/backup-$BDATE ]; then /bin/rm -f $DESTDIR/current /bin/ln -s $DESTDIR/backup-$BDATE $DESTDIR/current fi