Using rsync --link-dest continued, comments welcome
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) -- Chris Green
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)
date -d yesterday +%a works for me. Richard
On Thu, Mar 31, 2011 at 01:28:44PM +0100, Richard Parsons wrote:
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)
date -d yesterday +%a works for me.
Sadly my WD NAS doesn't know about 'yesterday' :- root@backup# date -d yesterday +%a date: invalid date `yesterday' root@backup# The NAS uses busybox for the bulk of its commands and 'date' is among those so I guess it's a fairly limited implementation. -- Chris Green
date -d yesterday +%a works for me.
Sadly my WD NAS doesn't know about 'yesterday' :-
root@backup# date -d yesterday +%a date: invalid date `yesterday' root@backup#
The NAS uses busybox for the bulk of its commands and 'date' is among those so I guess it's a fairly limited implementation.
Ah, busybox. http://www.google.co.uk/search?q=busybox+date+yesterday There's a solution here. Basically, you convert today's date into a number of seconds and then less 86400, before re-converting to a string. Richard
On Thu, Mar 31, 2011 at 01:41:22PM +0100, Richard Parsons wrote:
date -d yesterday +%a works for me.
Sadly my WD NAS doesn't know about 'yesterday' :-
root@backup# date -d yesterday +%a date: invalid date `yesterday' root@backup#
The NAS uses busybox for the bulk of its commands and 'date' is among those so I guess it's a fairly limited implementation.
Ah, busybox.
http://www.google.co.uk/search?q=busybox+date+yesterday
There's a solution here. Basically, you convert today's date into a number of seconds and then less 86400, before re-converting to a string.
I had considered that but wasn't convinced I could work out the exact syntax needed to do it, that link shows what's needed:- date -D %s -d $(( $(date +%s) - 86400)) +%a ... obvious really!? :-) Thank you. -- Chris Green
On 31/03/11 13:33, Chris G wrote:
Sadly my WD NAS doesn't know about 'yesterday' :- root@backup# date -d yesterday +%a date: invalid date `yesterday' root@backup#
The NAS uses busybox for the bulk of its commands and 'date' is among those so I guess it's a fairly limited implementation.
A trick I found via Google for a similar situation was: env TZ="UTC+24" date +%a but it's not something you can assume will work everywhere. Maybe it'll work for you? -- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) @ 13 Clarke Rd, Milton Keynes, MK1 1LG
participants (3)
-
Chris G -
Mark Rogers -
Richard Parsons