Step One: Create a backup script Oraclebackup.bat
First create a backup bat file, create a new backup directory oraclebackup under D, copy the EXP.EXE from the Oracle installation directory to this directory, and create a new text file Oraclebackup.txt with the following:
@echo off
@echo Delete the spare files and logs from 10 days ago
forfiles/p "D:\oraclebackup"/M *.rar/d -10/c "cmd/c del @path"
Set Filedir=e:\appsdata\works\orclbackup\btms
Set sysdate=%date:~0,4%-%date:~5,2%-%date:~8,2%.%time:~0,2%%time:~3,2%
Set filename=%expuser%~%orclsid%_%sysdate%
@echo backing up your Oracle database, wait a moment ...
Expsystem/[email protected]=d:/oraclebackup/mdb%filename%.dmp Log=d:/oraclebackup/mdb%filename%.log full=y feedback=10000 buffer=65535
@echo Mission Done!
@echo Start compressing database backups ...
"D:\Apps\Tools\WinRAR\Rar.exe" a%filename%.rar%filename%.dmp
"D:\Apps\Tools\WinRAR\Rar.exe" a%filename%.rar%filename%.log
@echo Database backup Compression complete!
When you're done, change the Notepad suffix txt to bat.
Double-click Oraclebackup.bat to test if you can back up normally.
Step Two: Create a new Windows scheduled task
Go to the Windows Control Panel, open the schedule and tasks, create a new task, click Browse, select the Oraclebackup.bat file under the new D-Disk Oraclebackup directory. Then choose 22:00 every night to execute, and then enter the local administrator password can be.
Note: Here I recorded, I encountered the problem, mainly because I have a user there are many tables, but now I do not need to backup all, only need to back up the XXX table,
OK, modify EXP statement exp System/[email protected] tables= (system.xxx%%) file=d:/oraclebackup/mdb%date:~0,4%%date:~5,2%%date:~ 8,2%.dmp Log=d:/oraclebackup/mdb%date:~0,4%%date:~5,2%%date:~8,2%.log full=y buffer=65535,
Note: The% inside the bat file must be%%!
Scheduled backup Oracle (Windows)