免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3315 | 回复: 2
打印 上一主题 下一主题

[备份软件] 转:Duplicate Veritas Netbackup Images [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-01 11:34 |只看该作者 |倒序浏览
无意中搜到的脚本,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

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
2 [报告]
发表于 2010-01-01 11:49 |只看该作者
钱是省了,管起来够麻烦的。

论坛徽章:
0
3 [报告]
发表于 2010-01-01 17:47 |只看该作者
:wink:
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP