编写自动处理脚本及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: