Script for daily DB2 backup

Source: Internet
Author: User

The following articles mainly describe the correct application of the script for daily DB2 backup. I accidentally found a script for daily DB2 backup on a reputable website, for your reference, the following is a detailed description of the article.

Script, daily

 
 
  1. mon_date="`date +%Y%m%d`" 
  2. YEAR=`date +%Y`  
  3. MONTH=`date +%m`  
  4. DAY=`date +%d`  
  5. tsdir="/DB2_backup/""$mon_date" 
  6. mkdir $tsdir  
  7. echo "/DB2_backup/""$mon_date" make done >> "$tsdir"/DB2backup.log  
  8. chmod -R 755 $tsdir  
  9. chown DB2admin:DB2grp1 $tsdir  

Delete the backup record one day ago

 
 
  1. echo "**************************DELETE BACKUP BEFORE TWO DAYS**********************" >> "$wkdir"/DB2backup.log  
  2. YESTEDAY=0 
  3. if [ "$DAY" = 01 ]  
  4. then  
  5. case $MONTH in  
  6. 01) YESTEDAY="$YEAR"1231 
  7. ;;  
  8. 02) YESTEDAY="$YEAR"0131 
  9. ;;  
  10. 03) YESTEDAY="$YEAR"0228 
  11. ;;  
  12. 04) YESTEDAY="$YEAR"0331 
  13. ;;  
  14. 05) YESTEDAY="$YEAR"0430 
  15. ;;  
  16. 06) YESTEDAY="$YEAR"0531 
  17. ;;  
  18. 07) YESTEDAY="$YEAR"0630 
  19. ;;  
  20. 08) YESTEDAY="$YEAR"0731 
  21. ;;  
  22. 09) YESTEDAY="$YEAR"0831 
  23. ;;  
  24. 10) YESTEDAY="$YEAR"0930 
  25. ;;  
  26. 11) YESTEDAY="$YEAR"1031 
  27. ;;  
  28. 12) YESTEDAY="$YEAR"1130 
  29. ;;  
  30. *) echo "$YESTEDAY" Occured error >> /DB2_backup/backup_error.log  
  31. exit 1  
  32. ;;  
  33. esac  
  34. else  
  35. YESTEDAY=`expr "$mon_date" - 7`  
  36. fi  
  37. DELETEDIRECTORY="/DB2_backup/""$YESTEDAY" 
  38. echo $DELETEDIRECTORY  
  39. if [ -d $DELETEDIRECTORY ]  
  40. then  
  41. rm -r "/DB2_backup/""$YESTEDAY"  
  42. echo "$DELETEDIRECTORY" delete complete >> "$tsdir"/DB2backup.log  
  43. else  
  44. echo "$DELETEDIRECTORY" is not exist >> "$tsdir"/DB2backup.log  
  45. fi   

The above content is an introduction to the script for daily DB2 backup. I hope you will find some gains.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.