windowns系統,oracle資料庫expdp自動備份

許願流星1號發表於2014-11-20

Create directory scott as 'D:\';

Grant read,write on directory scott to scott;

 

寫個.bat的程式,內容為

 

set backupfile=scott_%date:~0,4%-%date:~5,2%-%date:~8,2%.dmp

set logfile=scott_%date:~0,4%-%date:~5,2%-%date:~8,2%.log

D:\app\Administrator\product\11.2.0\dbhome_1\BIN\expdp scott/tiger@192.168.56.11/prod directory=scott  dumpfile=%backupfile%  logfile=%logfile%

 

rem delete 10days files

forfiles /p "d:\bak" /d -10  /c "cmd /c echo deleting @file ... && del /f @path"

 

備份出來的是:scott_2014-10-27.dmp

 

 

 

set backupfile=full_%date:~0,4%-%date:~5,2%-%date:~8,2%.dmp

set logfile=full_%date:~0,4%-%date:~5,2%-%date:~8,2%.log

D:\app\Administrator\product\11.2.0\dbhome_1\BIN\expdp system/oracle@192.168.56.11/prod directory=full full=y  dumpfile=%backupfile%  logfile=%logfile%

 

導整個資料庫

 

刪掉十天前的備份,執行下面的命令,就會把10天前d:\bak\的所有檔案都給刪除了。所以這個檔案下只能放備份

把這個命令也放到.bat裡

forfiles /p "d:\bak" /d -10  /c "cmd /c echo deleting @file ... && del /f @path"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29893219/viewspace-1340556/,如需轉載,請註明出處,否則將追究法律責任。

相關文章