cancel
Showing results for 
Search instead for 
Did you mean: 

Netbackup Script for Daily , Weekly and Monthly

netbackup_new1
Not applicable
Hi To All,

Im a newbie in netbackup system. Would like to ask some assistance about scripting. We have an existing Replication Manager (RM) that is doing the cloning of disk. and when the cloning is finish we then perform a backup. But we usualy encounter an error. It s because that the cloning is not yet finish and the backup schedule starts already. My boss ask me to create a script that will call to backup the disk after it finish the cloning. I see that we can put the script in the RM system to call it after if finish the cloning. My problem is that scheduling on backup.

we have Daily backup, Weekly backup and every 28 of the month fullbackup.

for daily = 1 week retention
for weekly = 2 weeks retention
for 28th of the month = 1 month retention.

How to create a script that will check if is Monday, Tuesday, Wednesday, Thursday, Friday, Saturday = Daily; Sunday will be Weekly and every 28th of the month is Monthly backup.

Please help me if you have a script that I can use for this setup.

Thank you very much,

Regards, Mike
4 REPLIES 4

David_McMullin
Level 6
Please respond with details of your OS, since that would determine what you can do.

There should be no problem with calling policy.schedule to backup policy.daily or policy.weekly, etc.

David_McMullin
Level 6
I did a google search for "unix day of week script" - here is the first entry:

http://www.unix.com/hp-ux/21052-get-day-week-date.html

#!/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
      }
  }
'

There are perl and bash as well...

Don't fear to do a little looking, instead of asking for all the answers.

James_Perry
Level 4
On a Unix/Linux OS.

The command date +%u gives you the numerical day of the week from 1=Monday to 7=Sunday so that gives you the day of the week to check against for your daily, weekly and monthly backups.

Using date +%d gives you the numerical day of the month.

So in psuedo code
Put the output of date +%u into some variable, say A.
Put the output of date +%d into another variable, say B.
If B = 28 you would run your monthly backup.
Else if A = 7 you would run your weekly backup.
Otherwise you run a daily backup.

You would use the bpbackup command to initiate the backup from the script based and pass it the daily, weekly, or monthly schedule for the required policies.

J_H_Is_gone
Level 6
This is mine from AIX
-----

we have a script that does a backup to disk. 
when the backup to disk is finsihed it test to see if it was good, if bad, sends email and scirpt ends.
if the backup to disk was good it continues on and does the backup of the disk files to tape.

I have a policy with USER SCHEDULES setup in it.
one Schedule is for weekend backup and one is for weekday backups

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"