Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2477557
  • 博文数量: 225
  • 博客积分: 11622
  • 博客等级: 上将
  • 技术积分: 7358
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-18 10:05
个人简介

我们的生活是多么美好呀!!!!

文章存档

2013年(2)

2012年(9)

2011年(59)

2010年(8)

2009年(35)

2008年(112)

分类: DB2/Informix

2011-11-16 17:20:18

[root@CCNDB18 ~]# cat /home/db2inst2/dbscript/Backup_CCTIW_DB.sh
#!/bin/bash
#chkconfig:2345 81 05
#description:backup cctiw database
#backup database
cd /home/db2inst2/dbscript
rm -df *.log
echo "BACKUP DATABASE... "`date` >> backup.log
#the name of DATABASE
db_name=THPDB
#the days of bakcup
day_keep=7
#the path of backup file
file_path="/home/db2inst2/"
#detail process: 1.detect db backup files to need remain; 2.delete backup invalid files;3.backup new db
begin_filename=$db_name".0.db2inst2.NODE0000.CATN0000."
end_filename="`date +%Y%m%d --date=$day_keep' days ago'`"
filename=$begin_filename$end_filename"*"
#find path
find $file_path -name $begin_filename"*" >> find.log
row_num=`wc find.log -l`
#backup db
echo "========BACKUP FILE========" >> backup.log
echo "========LINE NUM OF find.log : "$row_num >> backup.log
result="`db2 backup database $db_name online to $file_path`"
echo $result >> backup.log
mat=`expr "$result" : ".*Backup successful.*"`
echo $mat >> backup.log
if [ "$mat" -eq 0 ]
then
echo "========Because backup failed, save FILE NAME is "$filename >> backup.log
else
echo "========DELETE FILE NAME is "$filename >> backup.log
rm -df $file_path$filename
fi
echo "========BACKUP DATABASE EXECUTE FINISH========" >> backup.log
阅读(1574) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~