日期:2014-05-16  浏览次数:20485 次

Oracle11G RMAN备份和恢复笔记(二)

非catalog各种备份方式:
? 全库备份
??backup database;

? 增量备份:
??backup incremental level=0 database;
??backup incremental level=1 database;
??备注:level1级别备份在level0级别基础上才可以做.
?
?备份归档日志:
??backup database plus archivelog delete input;
?
??? 备份表空间:
??????? backup tablespace tbs_name;

??? 备份控制文件:
??????? backup current controlfile;
??????? backup database include current controlfile;
?
?备份数据文件:
???? backup datafile datafile_no;?
?
RMAN典型增量备份案例
?? 星期天: level 0 backup
?? 星期一: level 2 backuplevel 0 backup
?? 星期二: level 2 backup
?? 星期三: level 1 backup
?? 星期四: level 2 backup
?? 星期五: level 2 backup
?? 星期六: level 2 backup
实现思路:备份脚本+crontab
bakl0.sh
? run{
???? allocate channel channel0 type disk;
? backup
??? incremental level 0
????? format '/u01/rmanbak/inc0_%d_u_%T'
?? tag db_inc0
?? database;
?? release channel channel0;
? }
bakl1.sh
?? run{
?? allocate channel channel1 type disk;
?? backup
???? incremental level 1
??? format '/u01/rmanbak/inc1_%d_u_%T'
??? tag db_inc1
??? database;
??? release channel channel1;
??? }
bakl2.sh
?? run{
?? allocate channel channel2 type disk;
?? backup
???? incremental level 2
??? format '/u01/rmanbak/inc2_%d_u_%T'
??? tag db_inc2
??? database;
??? release channel channel2;
?? }
执行脚本:
?? rman target /msglog=bakl0.log cmdfile=bakl0.sh
?? rman target /msglog=bakl1.log cmdfile=bakl1.sh
?? rman target /msglog=bakl2.log cmdfile=bakl2.sh

添加自动执行的crontab??
crontab -e -u oracle(用户的定时计划)
45 23 * * 0 rman target /msglog=bakl0.log cmdfile=bakl0.sh
45 23 * * 1 rman target /msglog=bakl2.log cmdfile=bakl2.sh
45 23 * * 2 rman target /msglog=bakl2.log cmdfile=bakl2.sh
45 23 * * 3 rman target /msglog=bakl1.log cmdfile=bakl1.sh
45 23 * * 4 rman target /msglog=bakl2.log cmdfile=bakl2.sh
45 23 * * 5 rman target /msglog=bakl2.log cmdfile=bakl2.sh
45 23 * * 6 rman target /msglog=bakl2.log cmdfile=bakl2.sh
备注:建议指定全路径
重新启动定时任务服务
service crond restart;

备注:防止磁盘空间不足.

建议在使用rman备份注意一下两点:
1.dbid
2.配置.
? configure controlfile autobackup on;
? backup database plus archivelog delete input;
?

?例如:
?? backup format '/u01/rman/bak/full_%d_%t.bk' database plus archivelog delete input;
??
??
??
??
??
??
查看备份文件的目录:
?? show parameter db_recovery_file_dest;
?? show parameter db_recovery_file_dest_size;
查看恢复目录使用情况:
?? select * from v$flash_recovery_area_usage;
查看rman中默认的参数信息
?? show all;