Android auto-phone backup part 3

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: