Windows系統(tǒng)下Oracle數(shù)據(jù)庫每天自動(dòng)備份
linux和unix下面使用shell可以很方便實(shí)現(xiàn),如果windows環(huán)境下可以結(jié)合計(jì)劃任務(wù)實(shí)現(xiàn)
1.創(chuàng)建備份目錄d:ackup, 創(chuàng)建批處理命令Bak.bat,編寫備份腳本
exp user/passwd@orcl DIRECT=Y BUFFER=100000 FILE=D:ackupscdd%date:~0,10% OWNER=('scdd') LOG=D:ackupdata.log
forfiles /p "D:ackup" /s /m *.dmp /d -3 /c "cmd /c del @path"
說明:
exp命令是oracle提供的dump備份命令,其中的%date:~0,10%是DOS里取日期的命令,例如:C:Usersqyy>echo %date:~0,10%得到2016-11-30
forfiles是windows的文件查找命令,查找在backup,dmp后綴產(chǎn)生三天的文件,找到后執(zhí)行刪除操作
2.Windows定時(shí)任務(wù)每日自動(dòng)執(zhí)行批處理文件 3.保留最近三天的文件,自動(dòng)刪除以前日期的備份文件
forfiles參數(shù)說明:
/P 可是搜索的路徑。在我們這里就是要在哪個(gè)目錄尋找要?jiǎng)h除的文件
/M 根據(jù)搜索掩碼搜索文件。默認(rèn)為*,如果要找備份處dump文件,格式為*.dmp
/D 文件修改時(shí)間在某個(gè)時(shí)間之前或者之后。-3 表示3天之前的文件。
/s 包含子目錄
/C 表示為每個(gè)文件執(zhí)行的命令,如果要?jiǎng)h除該文件可以為"cmd /c del /F /s /q @file"。其中變量@file表示該文件名 f s q表示強(qiáng)制靜默刪除可以不用;cmd /c表示執(zhí)行字符串指定的命令然后終斷
其中@file可以返還如下結(jié)果,我們這里用@path
@file - returns the name of the file.
@fname - returns the file name without extension.
@ext - returns only the extension of the file.
@path - returns the full path of the file.
@relpath - returns the relative path of the file.
@isdir - returns "TRUE" if a file type is a directory, and "FALSE" for files. @fsize - returns the size of the file in bytes.
@fdate - returns the last modified date of the file.
@ftime - returns the last modified time of the file
以上就是介紹Windows系統(tǒng)下Oracle數(shù)據(jù)庫每天自動(dòng)備份,希望對(duì)大家有所幫助。