02-17-2010 05:52 AM
02-17-2010 07:56 AM
02-17-2010 08:09 AM
#!/bin/ksh date='2005-08-30' eval $(echo "${date}" | nawk -F- '{printf("year=%s month=%s day=%s\n", $1, $2, $3)}') echo "year->[${year}] month->[${month}] day->[${day}]" cal "${month}" "${year}" | nawk -v day="${day}" ' FNR > 2 { for(i=1; i <= NF; i++) if ( $i == day) { #printf("day->[%d] row->[%d]\n", $i, FNR-2) printf("%d\n", (NF == 7 || FNR!=3) ? i-1 : i+(6-NF)) exit } } '
02-17-2010 11:32 AM
02-17-2010 12:14 PM
BKUPDEV="/bkupfs1/mydir"
#Set policy for retention level in Veritas
CURRDT=`date +%a`
CUDHR=$(date +"%H")
#the next if is to test of it is thrusday morning it should be a thru backup
if [ $CUDHR -lt 17 -a $CURRDT = "Fri" ]
then
CURRDT="Thu"
fi
#if above is false then we keep what CURRDT had
if [ "$CURRDT" = "Fri" ] || [ "$CURRDT" = "Sat" ] || [ "$CURRDT" = "Sun" ];then
#this is a User Schedule with 6 month retention
VERSCHED=IFMXFriDatabase
else
#this is a User schedule with 2 week retention
VERSCHED=IFMXDatabase
fi
date >> /tmp/backup.log
print "Starting Veritas Backups - ${VERSCHED}" >> /tmp/backup.log
/opt/openv/netbackup/bin/bpbackup -p Policyname -s ${VERSCHED} -h $(hostname) -S Masterserver -t 0 -w ${BKUPDEV} >> /tmp/backup.log 2>&1
if [[ $? -ne 0 ]]
then
print "Veritas backup of ${BKUPDEV} failed."
else
print "Veritas Backup completed." >> /tmp/backup.log
fi
date >> /tmp/backup.log
#get rid of all the unneeded stuff before mailing.
cat /tmp/level0file|awk '($0 !~ /^warning:/&&$0 !~ /^Please/){print $0}'|mail -s "`uname -n` Successufl Level 0 to tape" "backupadmins@mycompany.com,dbaadmins@mycompany.com"