RMAN备份脚本及自动批处理(windows)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C:\Documents and Settings\Administrator>rman catalog tangtang/lenovoE520 target system/lenovoE520@tang
RMAN>show all;
设置控制文件的自动备份和自动备份的目录(建议设置,备份目录自定)
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'F:\backup\%F';
RMAN>exit;
按如上设置后,控制文件和spfile就会随着数据库备份自动备份到d:/backup下;
建立脚本文件和批处理文件:
脚本文件,如文件名为orabackup.rcv,具体内容如下:
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 0 database format 'F:\backup\level0_%d_%s_%p_%u.bak';
sql 'alter system archive log current';
backup archivelog all format 'F:\backup\log_%d_%s_%p_%u.bak' delete all input;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;
exit
批处理文件,如文件名为orabackup.bat,具体内容如下
rman catalog rmanuser1/rmanuser1@orada target system/system@oradb CMDFILE 'F:\backup\orabackup.rcv' LOG ’F:\backup\oracl_%date'
将orabackup.bat和orabackup.rcv存放在同一目录下,执行orabackup.bat就可以调用orabackup.rcv备份数据库了,你可以再windows的计划任务里执行orabackup.bat就可以自动备份了;
编写自动处理脚本及dos批处理文件进行rman备份
1)确定备份策略及配置,编写rman备份脚本,保存至E:\rman_bak\rman_scr.sql
脚本代码:
run
{
configure retention policy to recovery window of 7 days;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to 'F:\backup\%F';
allocate channel ch1 device type disk format 'F:\backup\%U';
backup database skip inaccessible filesperset 10
plus archivelog filesperset 20
delete all input;
release channel ch1;
}
allocate channel for maintenance device type disk;
crosscheck backupset;
delete noprompt obsolete;
2)编写dos批处理脚本 rman_src.bat
rman target / cmdfile='F:\backup\rman_scr.sql'>> F:\backup\log.txt
3)执行
可手工执行rman_src.bat进行备份;
或通过控制面板-> 任务计划中添加计划