您的位置:首页 > 数据库 > Oracle

oracle rman备份

2015-12-23 15:58 561 查看
rman  登录到cmd

打开cmd 输入 rmanconnect target jhpt/1@orcl
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 10plus archivelog filesperset 20delete all input;release channel ch1;}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete;2)编写dos批处理脚本 rman_src.batrman target / cmdfile='F:\backup\rman_scr.sql'>> F:\backup\log.txt3)执行可手工执行rman_src.bat进行备份;或通过控制面板-> 任务计划中添加计划
WINDOWS 上做的RMAN.sql内容如下:run{configure retention policy to recovery window of 7 days;configure controlfile autobackup on;configure controlfile autobackup format for device type disk to 'c:\backupb\%F_%T';allocate channel ch1 device type disk format 'C:\backupb\%T';backup database skip inaccessible filesperset 10plus archivelog filesperset 20delete all input;release channel ch1;}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete;11.bat (批处理文件)rman target / cmdfile='c:\backupb\rman.sql'>> c:\backupb\log.txt;简单的注释run{configure retention policy to recovery window of 7 days;configure controlfile autobackup on;--控制文件的自动备份configure controlfile autobackup format for device type disk to 'c:\backup\%F'; --控制文件目录allocate channel ch1 device type disk format 'c:\backup\%U'; --备份集的目录backup database skip inaccessible filesperset 10 --生成10个备份集plus archivelog filesperset 20delete all input;release channel ch1; --释放备份通道}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete; --删除未找到已废弃的备份(根据备份策略 目前的策略是保存最近7天的)在本机器上还原RMAN> shutdown immediateRMAN> startup mount;RMAN>restore database; --还原 指物理意义的文件的还原RMAN>recover database;--恢复 让数据一致最后打开数据库RMAN> alter database open--还原某一个时期的备份run{
allocate channel t1 device type disk;
set until time "to_date('2015-12-24 22:18:07','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: