Cribbed this backup script from a 'time machine' tutorial some time ago, and tweaked it for my purposes.