環境:windows server 2008 + oracle 10g R2 32bitsql
例一:windows
徹底備份:oracle
一、建立文件 full_backup.sql ,內容以下app
run{ CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS; allocate channel d1 type disk; //開啓多個通道 allocate channel d2 type disk; allocate channel d3 type disk; allocate channel d4 type disk; backup current controlfile format 'h:\rman_backup\ctl_%d_%s_%p_%u.bak'; //備份當前控制文件,並指定備份文件路徑 backup as compressed backupset full database format 'h:\rman_backup\full_%d_%s_%p_%u.bak'; //全庫備份,並指定備份文件存放路徑 sql 'alter system archive log current'; //切換歸檔日誌 backup archivelog all format 'h:\rman_backup\log_%d_%s_%p_%u.bak' delete all input; //備份全部歸檔日誌 release channel d1; //釋放通道 release channel d2; release channel d3; release channel d4; report obsolete; //報告過時或無效的備份 crosscheck backup; //交叉檢查備份 delete noprompt expired backup; //刪除過時的備份,不需交互確認 delete noprompt obsolete; //刪除無效的備份,不需交互確認 delete noprompt ARCHIVELOG until time 'SYSDATE-14'; //刪除14天前的備份歸檔日誌 }
二、新建bat文件full_backup.bat,內容以下:
ide
rman target / cmdfile='h:\rman_backup\script\full_backup.sql' log='h:\rman_backup\script\log\full_backup.log' append
三、把上述建立的兩個文件存放在相對應的路徑,而後在系統新建計劃任務執行full_backup.bat文件便可。日誌
例二:orm
一、建立增量0級備份文件level0_backup.sql,內容以下:blog
run{ CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS; allocate channel d1 type disk; allocate channel d2 type disk; backup incremental level=0 database include current controlfile format 'h:\rman_backup\level0_%d_%s_%p_%u.bak' plus archivelog format 'h:\rman_backup\log_%d_%s_%p_%u.bak'; release channel d2; release channel d1; report obsolete; crosscheck backup; delete noprompt expired backup; delete noprompt obsolete; delete noprompt ARCHIVELOG until time 'SYSDATE-30'; //刪除30天前的歸檔日誌 }
二、建立增量0級備份bat文件level0_backup.bat,內容以下:ip
rman target / cmdfile='h:\rman_backup\script\level0_backup.sql' log='h:\rman_backup\script\log\level0_backup.log' append
三、建立增量1級備份文件level1_backup.sql,內容以下:
run{ CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS; allocate channel d1 type disk; allocate channel d2 type disk; backup incremental level=1 database include current controlfile format 'h:\rman_backup\level1_%d_%s_%p_%u.bak' plus archivelog format 'h:\rman_backup\log_%d_%s_%p_%u.bak'; release channel d2; release channel d1; }
四、建立增量1級備份bat文件level1_backup.bat,內容以下:
rman target / cmdfile='h:\rman_backup\script\level1_backup.sql' log='h:\rman_backup\script\log\level1_backup.log' append
五、建立增量1c級備份文件level1c_backup.sql,內容以下:
run{ CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS; allocate channel d1 type disk; allocate channel d2 type disk; backup incremental level=1 cumulative database include current controlfile format 'h:\rman_backup\level1c_%d_%s_%p_%u.bak' plus archivelog format 'h:\rman_backup\log_%d_%s_%p_%u.bak'; release channel d1; release channel d2; report obsolete; crosscheck backup; delete noprompt expired backup; delete noprompt obsolete; delete noprompt ARCHIVELOG until time 'SYSDATE-30'; }
六、建立增量1級備份bat文件level1c_backup.bat,內容以下:
rman target / cmdfile='h:\rman_backup\script\level1c_backup.sql' log='h:\rman_backup\script\log\level1c_backup.log' append
按上圖計劃在系統中創建相對應的計劃任務執行上述bat文件便可。