RMAN备份脚本及自动批处理(windows)
接上章RMAN备份前工作: C:\Documents and Settings\Administrator>rman catalog rmanuser1/rmanuser1 target RMAN>show all; 设置控制文件的自动备份和自动备份的目录(建议设置,备份目录自定) RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON; RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'd:/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 'd:\backup\level0_%d_%s_%p_%u.bak'; sql 'alter system archive log current'; backup archivelog all format 'd:\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 target CMDFILE 'd:\backup\orabackup.rcv' LOG ’d:\backup\oracl_%date' 将orabackup.bat和orabackup.rcv存放在同一目录下,执行orabackup.bat就可以调用orabackup.rcv备份数据库了,你可以再windows的计划任务里执行orabackup.bat就可以自动备份了;