The automatic backup script for Oracle databases in Windows

Source: Internet
Author: User

The automatic backup script for Oracle databases in Windows

@ Echo off echo ============================================ ================= echo in Windows environment, the Oracle database's automatic backup script echo 1. use the current date to name the backup file. Echo 2. automatically delete the backup 30 days ago. Echo ===================================================== ==========:: The current time is retrieved in the format of "YYYYMMDD. Set BACKUPDATE = % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2% set CURTIME = % time :~ 0, 2% REM hours if less than 10, add 0if "% CURTIME %" = "0" set CURTIME = 00if "% CURTIME %" = "1" set CURTIME = 01if "% CURTIME %" = "2" set CURTIME = 02if "% CURTIME %" = "3" set CURTIME = 03if "% CURTIME %" = "4" set CURTIME = 04if "% CURTIME %" = "5" set CURTIME = 05if "% CURTIME %" = "6" set CURTIME = 06if "% CURTIME %" = "7" set CURTIME = 07if "% CURTIME % "=" 8 "set CURTIME = 08if" % CURTIME % "=" 9 "set CURTIME = 09 set CURTIME = % CURTIME % time: ~ 3,2% % time :~ 6, 2%: Set the user name, password, and database to be backed up. Set USER = carbon_zhenjiang_bakset PASSWORD = carbon_zhenjiang_bakset DATABASE = orcl: create a backup directory. If not exist "D: \ backup \ data \ % BACKUPDATE %" mkdir D: \ backup \ data \ % BACKUPDATE % if not exist "D: \ backup \ log \ % BACKUPDATE % "mkdir D: \ backup \ log \ % BACKUPDATE % set DATADIR = D: \ backup \ data \ % BACKUPDATE % set LOGDIR = D: \ backup \ log \ % BACKUPDATE % exp % USER %/% PASSWORD % @ % DATABASE % file = % DATADIR % \ % USER % _ % BACKUPDATE % CURTIME %. dmp log = % LOGDIR % \ log _ % BACKUPDATE % CURTIME %. log: Delete the backup that was created 30 days ago. Forfiles/p "% DATADIR %"/s/m *. */d-30/c "cmd/c del @ path" forfiles/p "% LOGDIR %"/s/m *. */d-30/c "cmd/c del @ path" exit

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.