以下的文章主要向大家描述的是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日常備份的腳本的介紹,望你能有所收獲。