Oracle Database Automatic Export backup script (in Windows)

Source: Internet
Author: User
Tags echo 7 net send
  1. Transferred fromOracle Database Automatic Export backup script (in Windows)
    Because WinRAR charges fees, I modified the script to use 7zip for compression.
  2. @ EchoOff
  3. @ Echo ===================================================== ============================================
  4. @ Echo the Oracle database's Automatic Export backup script (in Windows ).
  5. @ ECHO: Schedule orAtCommand settings are automatically executed.
  6. @ Echo ===================================================== ============================================
  7. @ Echo ===================================================== ==========================================
  8. @ Echo the Oracle database's Automatic Export backup script (in Windows ).
  9. @ ECHO: the following variables must be configured when the backup is started.
  10. @ Echo 1. backup_dir specifies the intermediate directory to be backed up. After compression is completed, it will be moved to the backup_warehouse directory.
  11. @ Echo 2. backup_warehouse specifies the storage location of historical backup data (compressed data) and logs
  12. @ Echo 3. oracle_username specifies the Oracle user name used for backup
  13. @ Echo 4. oracle_password specifies the Oracle password used for backup.
  14. @ Echo 5: oracle_db specifies the Oracle service name used for backup
  15. @ Echo 6. back_option backup option. It can be empty orFull= Y, can be owner = a user, B user or tables = () and so on ....
  16. @ Echo 7. rar_cmd specifies the directory where the RAR command line compression tool is located.
  17. @ Echo 8 and zip_cmd specify the directory where the 7zip command line compression tool is located (open-source free)
  18. @ Echo ===================================================== ==========================================
  19. @ Echo ===================================================== ======================
  20. @ Echo back up Database Service Data
  21. @ Echo ===================================================== ======================
  22. The following REM variables need to be configured according to the actual situation
  23. SetBackup_dir = D:/proj/dbbackup
  24. SetBackup_warehouse = D:/proj/dbbackup/File
  25. SetOracle_username =User
  26. SetOracle_password = pwd
  27. SetOracle_db = tnsname
  28. SetBack_option ="Owner = user"
  29. SetRar_cmd ="C:/program files (x86)/WinRAR/winrar.exe"
  30. SetZip_cmd ="C:/program files (x86)/7-zip/7z.exe"
  31. For/F"Tokens = 1, 2"%In('Date/t') DoSetToday = %
  32. Rem if the file name takes hours and minutes, use the first line of the following statement.
  33. RemSetBack_name = % oracle_db % _ % today % (%Time:~ 0, 2% hour %Time:~ 3, 2% )_
  34. SetBack_name = % oracle_db % _ % oracle_username % _ % today %
  35. SetBack_full_name = % backup_dir %/% back_name %
  36. Rem logs the operation to the batch processing log % back_full_name % _ bat. log.
  37. Echo =========================== backup database service data ========================== >>% back_full_name % _ bat. log
  38. Echo backup starts...> % back_full_name % _ bat. Log
  39. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  40. Exp % oracle_username %/% oracle_password % @ % oracle_db % grants = Y % back_option % file ="% Back_full_name %. dmp"Log ="% Back_full_name % _ exp. log"
  41. IfNotExist % backup_warehouse %/% back_name % _ logic (MD % backup_warehouse %/% back_name % _ logic)
  42. Echo compresses and deletes the original DMP file...> % back_full_name % _ bat. Log
  43. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  44. Rem uses 7zip to compress and comment out the WinRAR command.
  45. REM % rar_cmd % A-DF"%Back_name1__logic.rar" "% Back_full_name %. dmp"
  46. % Zip_cmd % A-tzip"%Back_name1__logic.zip" "% Back_full_name %. dmp"
  47. Rem Delete source file
  48. Del"% Back_full_name %. dmp"
  49. Echo"% Back_full_name % exp. log"
  50. Echo compresses and deletes the original DMP file! >>% Back_full_name % _ bat. Log
  51. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  52. Echo starts to move the file...> % back_full_name % _ bat. Log
  53. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  54. Rem uses 7zip to compress and comment out the WinRAR command.
  55. RemMove% Backup_dir %/*. rar % backup_warehouse %/% back_name % _ logic/
  56. Move% Backup_dir %/*. Zip % backup_warehouse %/% back_name % _ logic/
  57. ECHO file moved! >>% Back_full_name % _ bat. Log
  58. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  59. Rem net send % userdomain %"The logical backup of the database has been completed at: % date % time %! "
  60. Echo.
  61. Echo backup complete !!! >>% Back_full_name % _ bat. Log
  62. Echo current time: %Date%Time%> % Back_full_name % _ bat. Log
  63. Echo =================== the backup of Database Service data is complete !!! ==================>> % Back_full_name % _ bat. Log
  64. Move% Backup_dir %/*. Log % backup_warehouse %/% back_name % _ logic/
  65. Echo.
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.