此文章主要讲述的是实现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日常备份脚本的介绍,望你能有所收获。
【编辑推荐】