Amanda-Users

Re: Putting on my Amanda hat

2004-07-21 10:51:30
Subject: Re: Putting on my Amanda hat
From: Dave Sherohman <dsherohman AT westling DOT com>
To: Amanda List <amanda-users AT amanda DOT org>
Date: Wed, 21 Jul 2004 09:38:48 -0500
On Tue, Jul 20, 2004 at 05:13:46PM -0700, Mike Fedyk wrote:
> I have 10 tapes running daily with runspercycle 9 and dumpcycle 2 weeks.

Any chance of changing that to a 1-week cycle with 5 runspercycle?
In general, you want to have at least 2 cycles' worth of tapes, just
in case.  Having one extra tape is good, since it keeps you from ever
overwriting your most recent backup of anything, but it still doesn't
give much protection against bad backups.

> I want to have another cycle running every other Friday (two weeks), but 
> cron doesn't seem to be able to handle that.

`date +%U` gives you the week number in the year.  If there's an easy way
to test whether a number is even or odd in the shell, then that could be
used to run something from cron on only even/only odd-numbered weeks,
although there's still the possibility for anomalies at the end of the
year (week 52 -> week 00 is two evens in a row - but if this happens
every year, testing the evenness/oddness of year + week number would
solve it)...

OK, somewhat convoluted way to do it:

[ $(echo "$(date +\%U) \% 2" | bc) == 0 ] && /usr/local/sbin/backup-script

This will run /usr/local/sbin/backup-script on all even-numbered
weeks.  Change the 0 to 1 for odd weeks.  Also note that the %s need
to be backslash-escaped to prevent cron from intepreting them as
newlines/command separators.  (Only tested in bash, but, IIRC, the $()
syntax works in csh and vanilla sh also.)

Anyone have a simpler even/odd week test?


<Prev in Thread] Current Thread [Next in Thread>