此文章主要講述的是實現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日常備份腳本的介紹,望你能有所收獲。