Daily, weekly, monthly, yearly backup script

francs

ADSM.ORG Member
Joined
Jun 9, 2003
Messages
44
Reaction score
0
Points
0
Hi All

Some customers still like to do daily, weekly, monthly, yearly backups. Tsm don't really provide for it, so I created archive management groups for it and wrote this script to determine which type of backup should be done It then calls the tsm client with the correct management class. Hopefully someone can use this script and/or make some improvements/comments on it.

It is currently in use on an AIX 5.2 system.



Thanks



PS: It looks like you lose all indentation when it gets posted, so good luck with reading it.





#!/usr/bin/ksh



##############################################################################################

# Script to backup Kerridge filesystems after snapshot is finished.

# This script will determine if we should be doing a yearly, monthly, weekly or daily backup

# and call the TSM client with the appropriate management class for that day's backup.

# Author: F. Swanepoel from Faritec 011 800 7400

##############################################################################################



set -x



year=`date +%C%y`

doy=`date +%j`

dow=`date +%a`



let leapyear=${year}%4 #0=yes 1,2,3=no



type=""

if [ $leapyear -eq 0 ]

then

if [ ${doy} = 366 ]

then

type="yearly"



elif ([ ${doy} = '031' ] || [ ${doy} = '060' ] || [ ${doy} = '091' ] || [ ${doy} = '121' ] || [ ${doy} = '152' ] || [ ${doy} = '182' ] || [ ${doy} = '213' ] || [ ${doy} = '244' ] || [ ${doy} = '274' ] || [ ${doy} = '305' ] || [ ${doy} = '335' ])

then

type="monthly"

elif [ ${dow} = "Sun" ]

then

type="weekly"

else

type="daily"

fi

fi



if [ $leapyear -gt 0 ]

then

if [ ${doy} = 365 ]

then

type="yearly"



elif ([ ${doy} = '031' ] || [ ${doy} = '059' ] || [ ${doy} = '090' ] || [ ${doy} = '120' ] || [ ${doy} = '151' ] || [ ${doy} = '181' ] || [ ${doy} = '212' ] || [ ${doy} = '243' ] || [ ${doy} = '273' ] || [ ${doy} = '304' ] || [ ${doy} = '334' ])

then

type="monthly"

elif [ ${dow} = "Sun" ]

then

type="weekly"

else

type="daily"

fi

fi



# Now that we know which type of backup it is we start TSM client woth correct management class

case ${type} in

'yearly' )

dsmc arch "/fs/raid1/*" -subdir=yes -archmc=kerprodyrly

dsmc arch "/fs/raid2/*" -subdir=yes -archmc=kerprodyrly

dsmc arch "/fs/raid3/*" -subdir=yes -archmc=kerprodyrly

dsmc arch "/fs/raid4/*" -subdir=yes -archmc=kerprodyrly

dsmc arch "/fs/raid5/*" -subdir=yes -archmc=kerprodyrly

;;

'monthly' )

dsmc arch "/fs/raid1/*" -subdir=yes -archmc=kerprodmnly

dsmc arch "/fs/raid2/*" -subdir=yes -archmc=kerprodmnly

dsmc arch "/fs/raid3/*" -subdir=yes -archmc=kerprodmnly

dsmc arch "/fs/raid4/*" -subdir=yes -archmc=kerprodmnly

dsmc arch "/fs/raid5/*" -subdir=yes -archmc=kerprodmnly

;;

'weekly' )

dsmc arch "/fs/raid1/*" -subdir=yes -archmc=kerprodwkly

dsmc arch "/fs/raid2/*" -subdir=yes -archmc=kerprodwkly

dsmc arch "/fs/raid3/*" -subdir=yes -archmc=kerprodwkly

dsmc arch "/fs/raid4/*" -subdir=yes -archmc=kerprodwkly

dsmc arch "/fs/raid5/*" -subdir=yes -archmc=kerprodwkly

;;

'daily' )

dsmc arch "/fs/raid1/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid2/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid3/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid4/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid5/*" -subdir=yes -archmc=kerproddaily

;;

* )

dsmc arch "/fs/raid1/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid2/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid3/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid4/*" -subdir=yes -archmc=kerproddaily

dsmc arch "/fs/raid5/*" -subdir=yes -archmc=kerproddaily

;;

esac
 
Back
Top