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:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值