Amanda-Users

Re: Has anyone a script for Monthly/Daily backups

2005-08-17 14:04:56
Subject: Re: Has anyone a script for Monthly/Daily backups
From: Paul Bijnens <paul.bijnens AT xplanation DOT com>
To: "chuck.amadi" <chuck.amadi AT ntlworld DOT com>
Date: Wed, 17 Aug 2005 19:51:40 +0200
chuck.amadi wrote:
Has anyone a script that will check for the last friday of the month and if So run the monthly config backup or if not the usually daily config.

I am currently looking at hacking something together as I was just going to edit the crontab and comment and uncomment between daily and monthly.

I have a 10 tape run So a 2 week daily schedule but I to implement a monthly that will run on the last fridat of each month.


Is the "last friday of the month" a solid requirement or could it
be "the FIRST friday of the month" instead.

If yes:

===== cut here == Version 1
#!/bin/sh
# first friday of the month
if [ `date +%d` -lt 7 -a `date +%a` = "Fri" ]
then amdump monthly
else amdump daily
fi
====== cut here

====== cut here == Version 2, using one subprocess only
#!/bin/sh
# First friday of the month
case `date +%d%a` in
    [1-7]Fri) amdump monthly ;;
    *)  amdump daily ;;
esac
====== cut here


If the requirement is necessarily "the last Friday of the month"
the script becomes a little more complicated because the last friday
could fall in the fifth week of a month.
A python script is already posted, a shell script is here:

==== cut here ====
#!/bin/sh
# Last friday of the month
if [ `cal | awk 'NF >= 6 {print $6}' | tail -1` -eq `date +%d` ]
then amdump monthtly
else amdump daily
fi
====  cut here ===


--
Paul Bijnens, Xplanation                            Tel  +32 16 397.511
Technologielaan 21 bus 2, B-3001 Leuven, BELGIUM    Fax  +32 16 397.512
http://www.xplanation.com/          email:  Paul.Bijnens AT xplanation DOT com
***********************************************************************
* I think I've got the hang of it now:  exit, ^D, ^C, ^\, ^Z, ^Q, F6, *
* quit,  ZZ, :q, :q!,  M-Z, ^X^C,  logoff, logout, close, bye,  /bye, *
* stop, end, F3, ~., ^]c, +++ ATH, disconnect, halt,  abort,  hangup, *
* PF4, F20, ^X^X, :D::D, KJOB, F14-f-e, F8-e,  kill -1 $$,  shutdown, *
* init 0, kill -9 1, Alt-F4, Ctrl-Alt-Del, AltGr-NumLock, Stop-A, ... *
* ...  "Are you sure?"  ...   YES   ...   Phew ...   I'm out          *
***********************************************************************