Amanda-Users

Re: Has anyone a script for Monthly/Daily backups

2005-08-19 07:13:48
Subject: Re: Has anyone a script for Monthly/Daily backups
From: Chuck Amadi Systems Administrator <chuck AT smtl.co DOT uk>
To: Amanda List <amanda-users AT amanda DOT org>
Date: Fri, 19 Aug 2005 12:00:43 +0100
Hi all

I would like comments on this solution to run fortnight daily backup
using 10 tapes.
and on the last Friday of the month to run a Monthly backup for
archiving purposes and pull out of System until the following year.

I have hacked up two scripts from the this list.

First of all here is mt cronjob::
I need to know what tape is in the current tape drive be it the usual
daily tape
and of course if it happened to be the last friday in the month or say a
monday I will to put the next daily tape or on the thursday before the
last friday of the month backup to be ready to put the next monthly tape
in.

I am aware the amdump send a report on failures or successful backups
but
if a daily schedule is run and it's going to be a last friday and I put
in daily tape 
does the script ignore the daily tape and amdump monthly report So and
thus I can say on monday put in the monthly tape and run amflush.

Cheers


# Check which Amanda tape if Daily or Monthly.
0 14 * *  1-5 /usr/sbin/check_amanda_tape.sh

45 19 * * 1-5 /usr/sbin/last_friday_month.sh

Here is the Last Friday In Month script (last_friday_month.sh).
#!/bin/sh
# Script last_friday_month.sh
# chmod 755
# Amdump - Last friday of the month script to check prior to running
usual daily tape
# or the monthly tape backup.
# Ensure the in the amamda.conf file the within the dumptype
# paramter for root-tar that record is set to no 
# example - record no This is to stop Monthly ruining the Daily
Schedule.
# Summarisation of the script
# cal - prints month calendar
# awk - selects friday column date
# tail - last date
# -eq -  date compared last date with todays date.

if [ `cal | awk 'NF >= 6 {print $6}' | tail -1` -eq `date +%d` ]
then  su -c "/usr/sbin/amdump MonthlySet"
else  su -c "/usr/sbin/amdump DailySet1"

fi

Here is the Check which tape (check_amanda_tape.sh) is in the drive
prior to any amdumps running at 19:45

#!/bin/sh
# Script check_amanda_tape.sh
# chmod 755
# Amcheck - Last friday of the month script to check prior to running
usual daily tape
# or the monthly tape backup.
# Ensure the in the amamda.conf file the within the dumptype
# paramter for root-tar that record is set to no
# example - record no This is to stop Monthly ruining the Daily
Schedule.
# Summarisation of the script
# cal - prints month calendar
# awk - selects friday column date
# tail - last date
# -eq -  date compared last date with todays date.

if [ `cal | awk 'NF >= 6 {print $6}' | tail -1` -eq `date +%d` ]
then  su -c "/usr/sbin/amcheck MonthlySet"
else  su -c "/usr/sbin/amcheck DailySet1"

fi

                                                                                
                                                                              







On Thu, 2005-08-18 at 19:41 +0100, chuck.amadi wrote:
> Paul Bijnens wrote:
> 
> > chuck.amadi wrote:
> >
> >> Hi again do you run amcheck prior to amdump running. or is it a 
> >> simple caseof just hacking your script as below:
> >>
> >>
> >> #!/bin/sh
> >> # Script lfdom.sh
> >> # Last friday of the month script
> >> if [ `cal | awk 'NF >= 6 {print $6}' | tail -1` -eq `date +%d` ]
> >> then su -c "/usr/sbin/amcheck MonthlySet1"; su -c "/usr/sbin/amdump 
> >> MonthlySet1"
> >> else su -c "/usr/sbin/amcheck DailySet1"; su -c "/usr/sbin/amdump 
> >> DailySet1"
> >> fi
> >
> >
> >
> > amcheck is used to check for a valid tape and warn the sysadmin
> > if there is some problem.  Therefore, I run it during the day, when
> > I'm still there to correct things.
> > I do not run any additional amcheck just before launching the  amdump
> > program in the night.
> >
> > Therefore, I have two entries in my crontab.
> > One for amcheck, running at 16:15 Mon-Fri (in the hope that any
> > problems that might pop up can be still be solved before I go home.
> > Then another entry that just does amdump, running at 00:05 (yes, that's
> > actually the next day -- beware if you run the last-friday-of-month
> > check, in that case, start amdump just a few minute earlier, like 23:55).
> >
> >
> >
> Hi I used this script and my test was`successful without the amcheck But 
> I will a mail command to ensure that I put in a Monthly tape .
> 
> Cheers
> 
-- 
Unix/ Linux Systems Administrator
Chuck Amadi
The Surgical Material Testing Laboratory (SMTL), 
Princess of Wales Hospital 
Coity Road 
Bridgend, 
United Kingdom, CF31 1RQ.
Email chuck.smtl.co.uk
Tel: +44 1656 752820 
Fax: +44 1656 752830