更详细信息请转http://blog.chinaunix.net/uid-21187846-id-3017363.html
1,将目标数据库中控制文件的保存时间加长,默认是7天,这里修改为15天;这样比较保险,到时候恢复时也可以找到当时的备份元数据;
命令如下:
Alter system set control_file_record_keep_time=15 scope=both;
2,正式启用RMAN备份计划之前先清一下RMAN备份记录,否则RMAN备份时可能会报找不到已手工删除的归档日志:
rman>crosscheck archivelog all;
rman>delete expired archivelog all;
rman>crosscheck backup;
rman>delete expired backup;
3,创建备份目录
在E盘下面创建rmanbackup的备份目录
在E盘下面创建rmanbackuplog用来存放rman备份日志的文件夹
在E盘下面创建rmanbackupscripts来存放rman各个备份执行的脚本;
4.1Rman_Backup_full(数据库全备份)
Set oracle_sid=orcl--这个是目标数据库的实例名;
Rman target sys/orcl@orcl catalog rman/rman@orcl2 log='e:\rmanbackuplog\rman_backup_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%".log' cmdfile=e:\rmanbackupscripts\dbfull.rman
Exit;
Dbfull.rman的内容如下:
Run{
Allocate channel c1 type disk;
backup full database tag 'db0_%U_%S_%P' plus archivelog delete input format 'e:\rmanbackup\db0_%U_%S_%P' ;
release channel c1;
}
4.2 Rman_Backup_Level0.bat(0级备份)
Set oracle_sid=orcl--这个是目标数据库的实例名;
Rman target sys/orcl@orcl catalog rman/rman@orcl2 log='e:\rmanbackuplog\rman_backup0_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%".log' cmdfile=e:\rmanbackupscripts\ db0.rman
Exit;
db0.rman的内容如下:
Run{
Allocate channel c1 type disk;
backup incremental level 0 database tag 'db0_%U_%S_%P' plus archivelog delete input format 'e:\rmanbackup\db0_%U_%S_%P' ;
release channel c1;
}
4.3 Rman_Backup_Level_diff (1级差异增量备份)
Set oracle_sid=orcl--这个是目标数据库的实例名;
Rman target sys/orcl@orcl catalog rman/rman@orcl2 log='e:\rmanbackuplog\rman_backup1c_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%".log' cmdfile=e:\rmanbackupscripts\ diff.rman
Exit;
diff.rman的内容如下:
Run{
Allocate channel c1 type disk;
backup incremental level 1 database tag 'db1c_%U_%S_%P' plus archivelog delete input format 'e:\rmanbackup\db1c_%U_%S_%P' ;
release channel c1;
}
4.4 Rman_Backup_Level_diff (1级累积增量备份)
Set oracle_sid=orcl--这个是目标数据库的实例名;
Rman target sys/orcl@orcl catalog rman/rman@orcl2 log='e:\rmanbackuplog\rman_backup1add_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%".log'cmdfile=e:\rmanbackupscripts\ add.rman
Exit;
add.rman的内容如下:
Run{
Allocate channel c1 type disk;
backup incremental level 1 cumulative database tag 'db1add_%U_%S_%P' plus archivelog delete input format 'e:\rmanbackup\db1add_%U_%S_%P' ;
release channel c1;
}
----------------------------------------------------------------
备份策略
每个月做一次数据库全备份(利用Rman_Backup_full.bat)
每周日晚11:59做数据库0级备份(利用Rman_Backup_Level0.bat)
每周一、二、四、五、六晚11:59做1级差异增量备份(利用Rman_Backup_Level_diff.bat)
每周三晚11:59做数据库1级累积增量备份 (利用Rman_Backup_Levell_add.bat)
这样就可以用周为单位循环备份数据库;