rman備份腳本(收集學習)

編寫自動處理腳本及dos批處理文件進行rman備份

1)確定備份策略及配置,編寫rman備份腳本,保存至E:\rman_bak\rman_scr.sql

腳本代碼:

run

{

configureretention policy to recovery window of 7 days;

configurecontrolfile autobackup on;

configurecontrolfile autobackup format for device type disk to'e:/rman_bak/%F';

allocatechannel ch1 device type disk format'e:\rman_bak\%U';

backupdatabase skip inaccessible filesperset 10

plusarchivelog filesperset 20

deleteall input;

releasechannel ch1;

}

allocatechannel for maintenance device type disk;

crosscheckbackupset;

deletenoprompt obsolete;

2)編寫dos批處理腳本rman_src.bat

rmantarget /cmdfile='e:\rman_bak\rman_scr.sql'>>e:\rman_bak\log.txt

3)執行

可手工執行rman_src.bat進行備份;

或通過控制面板-> 任務計劃中添加計劃

查看log文件,備份OK!

 


 

RMAN的參數

先決條件:必須在操作系統命令行中發出RMAN命令和任何選項,而不是在RMAN提示符中。

Cmdfile:

Parses and compiles all RMAN commands in a file and then sequentiallyexecutes each command in the file. RMAN exits if it encounters a syntax errorduring the parse phase or if it encounters a run-time error during theexecution phase. If no errors are found, then RMAN exits after the jobcompletes.

If the firstcharacter of the file name is alphabetic, then you can omit the quotes aroundthe file name. The contents of the command file must be identical to commandsentered at the RMAN prompt.

Note: If you runa command file at the RMAN prompt rather than as an option on the operatingsystem command line, then RMAN does not run the file as asingle job. RMAN reads each line sequentially and executes it, only exitingwhen it reaches the last line of the script.

Log:

Specifies the file where RMAN records its output, that is, the commandsthat were processed and their results. RMAN displays command input at theprompt but does not display command output, which is written to the log file.By default RMAN writes its message log file to standard output.

RMAN output isalso stored in the V$RMAN_OUTPUT view, which is a memory-only viewfor jobs in progress, and in V$RMAN_STATUS, which is a control file view forcompleted jobs and jobs in progress.

The LOG parameterdoes not cause RMAN to terminate if the specified file cannot be opened.Instead, RMAN writes to standard output.

Note: Theeasiest way to send RMAN output both to a log file and to standard output is touse the Linux tee command or its equivalent. For example:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章