Well here's my initial attempt at writing the incremental backup using rsync's --link-dest :-
#!/bin/ash # # # Backup script run daily # dirs="chris dps laptop"
today=`date +%a`
case $today in "Sun") yesterday="Sat";; "Mon") yesterday="Sun";; "Tue") yesterday="Mon";; "Wed") yesterday="Tue";; "Thu") yesterday="Wed";; "Fri") yesterday="Thu";; "Sat") yesterday="Fri";; esac
for dir in $dirs do # # # remove last week's backup # rm -fr /ExtendVolume/$dir/$today # # # Run rsync to create a new backup for today # rsync -a --link-dest=/ExtendVolume/$dir/$yesterday /DataVolume/$dir/ /ExtendVolume/$dir/$today done
It works to the extent that it's creating the backup for 'today' on /ExtendVolume, I'll have to wait until tomorrow before I can tell if it's doing the hard links right. I get a warning error today of course:-
--link-dest arg does not exist: /ExtendVolume/chris/Wed
but that's fine, it's actually quite encouraging! :-)
If anyone can suggest a better way of working out 'yesterday' than that horrible case sequence I'd love to see it. While the case works it grates rather when I look at it! (It has to be in ash or sh, the NAS doesn't have bash or similar)