- 论坛徽章:
- 0
|
无意中搜到的脚本,duplicate 替代vault ,原文:http://www.panix.com/~kylet/nbdup.html
Duplicate Veritas Netbackup Images
This page shows a script I use to duplicate images from Netbackup to be stored offsite. I did this as I refused to pay Veritas $10K for their "Vault" software addon. This setup uses three media pools (OFFSITE[1-3]) which are rotated weekly such that 2 copies are offsite at any given time, with Tuesday being the pickup/drop-off day. My backup server is "ipswich". This script runs each Sunday AM. Also, here is a companion script that will check to make sure the right tapes are loaded for the next run of the duplicate script.
Please let me know if you have any suggestions or improvements for this script.
#!/bin/ksh
# Duplicate NetBackup images
# Top directory for files
TOPDIR=/usr/local/lib/netbackup
# Who to notify
MAILTO=kylet
# File used to keep sequence rotation
OFFSITEFILE=${TOPDIR}/.offsite
# For errors
ERRLOG=${TOPDIR}/nbdup.err
# For the work file
WRKFILE=${TOPDIR}/nbdup.wrk
# For the log file
LOG=${TOPDIR}/nbdup.log
# The date a week ago for determining what sessions to duplicate
WEEKAGO=`/tools/bin/date --date=-1week +%D`
# When to expire this duplicate set due to 2 copy limit
EXPIREDATE=`/tools/bin/date --date=+12days +%D`
# When this set will come back from offsite rotation
TAPERETURN=`/tools/bin/date --date=Tuesday+2weeks +%D`
if [ ! -s $OFFSITEFILE ]
then
OFFSITENUM=1
else
OFFSITENUM=`cat $OFFSITEFILE`
case $OFFSITENUM in
1)
OFFSITENUM=2
NEXTRUN=3
TAPES="80-89"
;;
2)
OFFSITENUM=3
NEXTRUN=1
TAPES="90-99"
;;
3)
OFFSITENUM=1
NEXTRUN=2
TAPES="70-79"
;;
*)
OFFSITENUM=1
TAPES="70-79"
;;
esac
fi
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
DESTPOOL=OFFSITE${OFFSITENUM}
echo $OFFSITENUM > $OFFSITEFILE
# List clients to act on and then duplicate all their full backup images for the past week
for CLIENT in `/usr/openv/netbackup/bin/admincmd/bpimagelist -L -d $WEEKAGO -st FULL | grep "^Client: " | awk ' { print $2 } ' | sort -u`
do
/usr/openv/netbackup/bin/admincmd/bpduplicate -dstunit ipswich_sto -client $CLIENT -st FULL -v -L $LOG -dp $DESTPOOL -shost ipswich -s $WEEKAGO
if [ $? -ne 0 ]
then
echo "Error with backup of $CLIENT" >> $ERRLOG
fi
done
# Duplicate Oracle backups for the last week
/usr/openv/netbackup/bin/admincmd/bpduplicate -dstunit ipswich_sto -ct Oracle -v -L $LOG -dp $DESTPOOL -shost ipswich -s $WEEKAGO
if [ $? -ne 0 ]
then
echo "Error with backup of Oracle" >> $ERRLOG
fi
# Expire media in offsite destination media pool
for MEDIAID in `/usr/openv/netbackup/bin/admincmd/bpmedialist -p $DESTPOOL | grep "^00" | awk ' { print $1 }`
do
for BACKUPID in `/usr/openv/netbackup/bin/admincmd/bpimmedia -mediaid $MEDIAID -l | grep "^IMAGE " | awk ' { print $4 }`
do
/usr/openv/netbackup/bin/admincmd/bpexpdate -backupid $BACKUPID -d $EXPIREDATE 00:00:00 -copy 2 -force
done
done
echo "\nPrepare offsite set $OFFSITENUM (Tapes $TAPES)" > $WRKFILE
echo "Iron Mountain label number: 6549CL${OFFSITENUM}" >> $WRKFILE
echo "Return date for ${DESTPOOL}: ${TAPERETURN}" >> $WRKFILE
echo "Next offsite pool: OFFSITE${NEXTRUN}" >> $WRKFILE
echo "State of tapes in pool: ${DESTPOOL}\n" >> $WRKFILE
/usr/local/scripts/avmedia $DESTPOOL >> $WRKFILE
echo "\n" >> $WRKFILE
if [ -s $ERRLOG ]
then
cat $ERRLOG >> $WRKFILE
cat $LOG >> $WRKFILE
cat $WRKFILE | mailx -s "NetBackup Offsite Status (with errors)" $MAILTO
else
cat $LOG >> $WRKFILE
cat $WRKFILE | mailx -s "NetBackup Offsite Status" $MAILTO
fi
mv $WRKFILE $LOG
rm -f $ERRLOG |
|