以下的文章主要向大家描述的是DB2日常备份的脚本的正确应用,我无意间在一个信誉度很好的网站找到一个关于DB2日常备份的脚本的资料,拿出来供大家分享,以下就是文章的详细内容介绍,望大家借鉴。
脚本, 日常
- mon_date="`date +%Y%m%d`"
- YEAR=`date +%Y`
- MONTH=`date +%m`
- DAY=`date +%d`
- tsdir="/DB2_backup/""$mon_date"
- mkdir $tsdir
- echo "/DB2_backup/""$mon_date" make done >> "$tsdir"/DB2backup.log
- chmod -R 755 $tsdir
- chown DB2admin:DB2grp1 $tsdir
删除1天前的备份记录
- echo "**************************DELETE BACKUP BEFORE TWO DAYS**********************" >> "$wkdir"/DB2backup.log
- YESTEDAY=0
- if [ "$DAY" = 01 ]
- then
- case $MONTH in
- 01) YESTEDAY="$YEAR"1231
- ;;
- 02) YESTEDAY="$YEAR"0131
- ;;
- 03) YESTEDAY="$YEAR"0228
- ;;
- 04) YESTEDAY="$YEAR"0331
- ;;
- 05) YESTEDAY="$YEAR"0430
- ;;
- 06) YESTEDAY="$YEAR"0531
- ;;
- 07) YESTEDAY="$YEAR"0630
- ;;
- 08) YESTEDAY="$YEAR"0731
- ;;
- 09) YESTEDAY="$YEAR"0831
- ;;
- 10) YESTEDAY="$YEAR"0930
- ;;
- 11) YESTEDAY="$YEAR"1031
- ;;
- 12) YESTEDAY="$YEAR"1130
- ;;
- *) echo "$YESTEDAY" Occured error >> /DB2_backup/backup_error.log
- exit 1
- ;;
- esac
- else
- YESTEDAY=`expr "$mon_date" - 7`
- fi
- DELETEDIRECTORY="/DB2_backup/""$YESTEDAY"
- echo $DELETEDIRECTORY
- if [ -d $DELETEDIRECTORY ]
- then
- rm -r "/DB2_backup/""$YESTEDAY"
- echo "$DELETEDIRECTORY" delete complete >> "$tsdir"/DB2backup.log
- else
- echo "$DELETEDIRECTORY" is not exist >> "$tsdir"/DB2backup.log
- fi
以上的相关内容就是对DB2日常备份的脚本的介绍,望你能有所收获。
【编辑推荐】