db2自动备份脚本
来源:未知 责任编辑:智问网络 发表时间:2013-09-02 11:42 点击:次
p>db2自动备份脚本
p>
p>
#!/bin/bash #db2自动备份脚本 # create at 2013-07-24 #--------------------------- #参数 dblist1=BOYA #要备份的数据库 dblist2=BOYACZ bkrootpath=~/backup #备份路径 bkdate=`date +%Y%m%d` #备份时间 bkpath=${bkrootpath}/${bkdate} log=${bkdate}.log #日志 date=`date +%Y%m%d%k%M%S` backfile1=${dblist1}.0.db2inst1.NODE0000.CATN0000.${date} backfile2=${dblist2}.0.db2inst1.NODE0000.CATN0000.${date} #初始化db2环境 if [ -f ${HOME}/sqllib/db2profile ]; then . ${HOME}/sqllib/db2profile fi #创建备份路径 if [ -d ${bkrootpath} ];then echo "" else mkdir ${bkrootpath} fi if [ -d ${bkpath} ];then cd ${bkpath} echo "今天已备份">>${log} else mkdir ${bkpath} cd ${bkpath} fi db2stop force #停止db2数据库 db2start #重启db2数据库,以保证备份正常进行 echo "----------------------">${log} echo "${bkdate}">>${log} echo "">>${log} echo "所要备份数据库列表">>${log} echo "${dblist1},${dblist2}">>${log} #连接备份数据库1 db2set db2codepage=1386 db2 connect to ${dblist1} echo "开始备份${dblist1}">>${log} echo "正在备份......">>${log} db2 backup db ${dblist1} to "${bkpath}" if [ -d "${backfile1}" ];then echo "成功备份数据库${dblist1}">>${log} else echo "备份数据库${dblist1}失败">>${log} fi db2stop force db2start #连接备份数据库2 db2set db2codepage=1386 db2 connect to ${dblist2} echo "开始备份${dblist2}">>${log} echo "正在备份......">>${log} db2 backup db ${dblist2} to "${bkpath}" if [ -d "${backfile2}" ];then echo "成功备份数据库${dblist2}">>${log} else echo "备份数据库${dblist2}失败">>${log} fi
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>