An excellent Oracle automatic backup script (exp for WINDWS)
Zhu Xiaoque
Time:
2011-5-12
First, the contents of the script
Set mydate=%date:~0,10%
Exp System/[email protected] full=y file=d:\ora_bak\data\hzic_%date%.dmp
Log=d:\ora_bak\log\hzic-log_%mydate%.log
forfiles/p "D:\ora_bak\data"/s/m * */d-7/C "cmd/c del @path"
forfiles/p "D:\ora_bak\log"/s/m * */d-7/C "cmd/c del @path"
Note: You only need to copy the above content to Notepad, save As. bat file, note the line, the above is actually 4 lines of content. Schedule settings for automatic backups that can be easily done with Windows Task Scheduler.
Ii. Explanatory Notes
1, set mydate=%date:~0,10%: Set the date variable, in order to automatically use the current date to name when backing up the exported file. 0 for start position, 10 for 10 characters from start position
2, exp system/[email protected] full=y file=d:\ora_bak\data\hzic_%date%.dmp log=d:\ora_bak\log\hzic-log_%mydate%. Log
Use sytem account to export the whole library, the exported data files are stored in the D:\ora_bak\log directory, the exported log files are stored in the D:\ora_bak\log directory.
3, forfiles/p "D:\ora_bak\log"/s/m * * */d-7/C "cmd/c del @path": Automatic deletion of 7 days ago Backup, detailed instructions see the following accessories
--------------------------------------------
new text document paste the following script content:
@echo off
setlocal
set sid=? Modify the SID value according to the actual situation
set username=? Assign a value
set password= according to the actual situation? Assign a value
set bakdir= according to the actual situation? Fill in the backup path according to the actual situation
Set bakdate=%date:~0,10%
Set connect=%username%/%password%@%sid%
Exp%connect% full=y buffer=64000000 file=%bakdir%\%bakdate%.dmp log=%bakdir%\exp%bakdate%.log
forfiles/p%bakdir%/d-10-c "cmd/c del/ f/q @path "//delete files 10 days ago
Endlocal
Save as BAT file (for example: Aa.bat), add tasks to the system's scheduled tasks, specify to run the script 02:00 every day
-------- -----------------------------------------
New text Document paste the following script content:
@echo off
Setlocal
Set sid=? Modify the SID value according to the actual situation
Set username=? Assign value according to actual situation
Set password=? Assign value according to actual situation
Set bakdir=? Fill in the backup path according to the actual situation
Set bakdate=%date:~0,10%
Set connect=%username%/%password%@%sid%
Exp%connect% full=y buffer=64000000 file=%bakdir%\%bakdate%.dmp log=%bakdir%\exp%bakdate%.log
forfiles/p%bakdir%/d-10-c "cmd /C del/f/q @path" //delete files 10 days ago
Endlocal
After you save as a bat file (for example: Aa.bat), add tasks to the system's scheduled tasks, specifying that the script runs 02:00 every day.
Oracle Automatic Backup