首页 > 代码库 > db2定时任务、备份脚本

db2定时任务、备份脚本

[db2inst1@db2 ~]$ crontab -l

30 02 * * *  /bin/sh  /home/db2inst1/backup/backup.sh

[db2inst1@db2 ~]$ cat /home/db2inst1/backup/backup.sh

#!/bin/bash

bakdir=/home/db2inst1/backup

time1=`date  +"%Y-%m-%d %H:%M:%S"`

cd $bakdir

echo $time1 >> $bakdir/backup.log

/home/db2inst1/sqllib/bin/db2 backup db devdb104 online

if [ $? -eq 0 ];then

time2=`date  +"%Y-%m-%d %H:%M:%S"`

echo "the database backup is successfully completed at $time2" >> $bakdir/backup.log

else

echo "the database backup is failed" >> $bakdir/backup.log

fi

/bin/find /home/db2inst1/backup/ -type f -iname "devdb104.0.db2inst1.NODE0000.CATN0000*" -mtime +1 -exec rm -rf {} \; 


本文出自 “arvin_0213” 博客,请务必保留此出处http://arvin0213.blog.51cto.com/2455782/1929593

db2定时任务、备份脚本