Oracle Database automatic Backup implementation effect
- Export DMP format files using the Oracle EXP command;
- Automatically compress DMP files using 7z command line to reduce storage space;
- Use Windows timed tasks to automatically back up, and periodically delete backups up to n days;
Backup Bat Command
@echo offrem ********************** configuration start **********************rem connect Oracle IP Port database name set SID=127.0.0.1:1521/orclrem User Name set username connected to Oracle=orclrem connecting Oracle's password set password=123the REM backup file folder for example (D:\bak) set Bak_path=D:\bakrem 7za.exe Compressed file path set Rar_path=D:\bak\7za.exerem ********************** configuration end **********************set Connect=%username%/%password%@%sid%echo Delete 7 days ago the spare files and log 7z files forfiles/p%bak_path%/M *.dmp/d-7/c "cmd/c del @path"forfiles/p%bak_path%/M *.log/d-7/c "cmd/c del @path"forfiles/p%bak_path%/M *.7z/d-7/c "cmd/c del @path"Echo start back up REM If the backup folder does not exist, create an if not exist"%bak_path%" mkdir "%bak_path%"Set filename=oraclebak%date:~0,4%%date:~5,2%%date:~8,2%set filepath=%BAK_PATH%\%FILENAME%REM execute EXP EXPORT command exp%connect% file=%filepath%.dmp owner=%username% log=%filepath%.log indexes=y grants=y constraints=y compress=Yrem If there is 7za.exe then perform compression, there is no direct exit if exist%rar_path% (%rar_path% a%filepath%.7z%filepath%.dmp%filepath%.logrem Delete dmp files after compression if errorlevel0(del%filepath%.dmpdel%filepath%.log)) Else (Echo compressed file does not exist, DMP does not compress exit) exit
Save the above text as a bat file, and the new Windows scheduled task executes the Bat command periodically for scheduled backups.
Oracle automatically backs up DMP files