Windows系統下Oracle資料庫每天自動備份_oracle

來源:互聯網
上載者:User

linux和unix下面使用shell可以很方便實現,如果windows環境下可以結合計劃任務實現

1.建立備份目錄d:\backup, 建立批處理命令Bak.bat,編寫備份指令碼

exp user/passwd@orcl DIRECT=Y BUFFER=100000 FILE=D:\backup\scdd%date:~0,10% OWNER=('scdd') LOG=D:\backup\data.log forfiles /p "D:\backup" /s /m *.dmp /d -3 /c "cmd /c del @path"

說明:

exp命令是oracle提供的dump備份命令,其中的%date:~0,10%是DOS裡取日期的命令,例如:C:\Users\qyy>echo %date:~0,10%得到2016-11-30

forfiles是windows的檔案尋找命令,尋找在backup,dmp尾碼產生三天的檔案,找到後執行刪除操作

2.Windows定時任務每日自動執行批次檔 3.保留最近三天的檔案,自動刪除以前日期的備份檔案

forfiles參數說明:

/P 可是搜尋的路徑。在我們這裡就是要在哪個目錄尋找要刪除的檔案

/M 根據搜尋掩碼搜尋檔案。預設為*,如果要找備份處dump檔案,格式為*.dmp

/D 檔案修改時間在某個時間之前或者之後。-3 表示3天之前的檔案。

/s 包含子目錄

/C 表示為每個檔案執行的命令,如果要刪除該檔案可以為"cmd /c del /F /s /q @file"。其中變數@file表示該檔案名稱 f s q表示強制靜默刪除可以不用;cmd /c表示執行字串指定的命令然後終斷

其中@file可以返還如下結果,我們這裡用@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系統下Oracle資料庫每天自動備份,希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.