Amanda-Users

Re: Crontab Sanity Check

2005-03-22 11:39:16
Subject: Re: Crontab Sanity Check
From: Gaby vanhegan <gaby AT vanhegan DOT net>
To: amanda-users AT amanda DOT org
Date: Tue, 22 Mar 2005 16:30:31 +0000

On 22 Mar 2005, at 15:07, Jon LaBadie wrote:

1) As you do, I used to believe the relationship of DOM and DOW
   (day of month/week) was an AND type relationship.  So the data
   and time would have to match 1-7 AND 4.  But it is not.  Instead
   it is an OR relationship.  Any of the first 7 days, or Thursdays.

    The way to handle what you want to do is start a script from a
    crontab.  The script will determine if it is appropriate to start
    the amdump or amcheck.  The script could run every day and check
    for DOM 1-7/DOW 4, or it could run every DOW 4 and check DOM 1-7,
    or every DOM 1-7 and check for DOW 4.

This is exactly why I sanity checked it... Thank you John :) I now have:

# Daily Amanda backup run
0 16 * * * /usr/local/etc/amanda/amanda.amcheck.cron 45 0 * * * /usr/local/etc/amanda/amanda.amdump.cron

And the relevant excerpt from amanda.amcheck.cron:

# When should we run a full backup?
RUNDAY=4
RUNBEFORE=7

# What day of the month and week is it?
DOW=`/bin/date "+%u"`
DOM=`/bin/date "+%e"`

# If it's the day we run and within the date range, run a full backup check
if [ "$DOW" = "$RUNDAY" ]; then
    if [ "$DOM" -le "$RUNBEFORE" ]; then
        sudo -u operator /usr/local/sbin/amcheck ltsn_full
        touch /usr/local/etc/amanda/amanda.runfull
    fi
fi

And from amanda.amdump.cron:

# If we are supposed to run the file, run it.
if [ -f /usr/local/etc/amanda/amanda.runfull ]; then
    sudo -u operator /usr/local/sbin/amdump ltsn_full
    rm /usr/local/etc/amanda/amanda.runfull
fi

This gets round a problem with running amdump and amcheck on separate days. If amcheck was run on thursday night at the end of the month then amdump would run without running amcheck. Alternatively, if amcheck was run on the 7th of the month, amdump would not run. Alternatively, adjusting RUNBEFORE and RUNDAY in amanda.amdump would possibly result in double full dumps happening. This way amcheck is only run once for the full dump config and amdump is only run if amcheck is run. I can also force a full dump by:

# touch /usr/local/etc/amanda/amanda.runfull

2) You are running amcheck at 5 PM, 16 hours AFTER the amdump has
   already run.  It is too late to do anything about the amcheck
   then.  Remember, the 12:45 AM you probably meant is the next
   day, Friday.  In fact, 5 PM may be too late anyway.  Will you
   be there to check your mail after 5?

That one I spotted and have corrected, as above :)

Gaby

--
Uganda Maximum - Enemy of the English Thrust
gaby AT vanhegan DOT net
http://weblog.vanhegan.net


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