oracle数据库rman备份计划及恢复
2.rman备份脚本:
a.RMAN 0级备份命令:
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level 0 tag 'level0' format "E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\RFDB_level_0_%u_%s_%p" as compressed backupset
database;
sql "alter system archive log current";
backup filesperset 3 format "E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\arch_%u_%s_%p_%c"
archivelog all delete input; #备份归档可选,可以单独定期备份
release channel c1;
release channel c2;
release channel c3;
}
b.RMAN 1级备份命令:
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level 1 tag 'level1' format 'E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\RFDB_level_1_%u_%s_%p' as compressed backupset
database;
sql 'alter system archive log current';
backup filesperset 3 format 'E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\arch_%u_%s_%p'
archivelog all delete input; #备份归档可选,可以单独定期备份
release channel c1;
release channel c2;
release channel c3;
}
c.rman删除备份命令(在保留最近一天备份的情况下,删除其他备份):
DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 1 DAYS;
d.操作系统层面运行rman备份或删除命令(windows/linux):
rman target sys/rf4rfvbgt56yhn@rfdb nocatalog CMDFILE 'D:\app\rman\rman_file\level_0.txt' log=E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\log\rman_level_0.log
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db1
export ORACLE_SID=atest
export PATH=$ORACLE_HOME/bin:$PATH
rman target sys/123456@atest nocatalog CMDFILE '/u01/rman/rman.sh' log=/u01/rman/rman.log
00 02 * * 1 bash /u01/rman_file/run_rman_0.sh
00 02 * * 3 bash /u01/rman_file/run_rman_0.sh
00 02 * * 5 bash /u01/rman_file/run_rman_0.sh
00 04 * * * bash /u01/rman_file/run_delete.sh
34 11 * * * bash /u01/rman_file/run_rman_0.sh
e.rman参数设置:
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE disk TO 2;
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE disk TO 2;
3.rman恢复 a.拷贝datafile,controlfile和spfile的rman备份,以及完整的archivelog和完好的redolog文件到新的数据库。 b.切换至oracle用户,进入rman(先设置sid):
export ORACLE_SID=rfdb
rlwrap rman target /
c.启动一个伪实例:
RMAN> startup nomount
connected to target database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db1/dbs/initrfdb.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 281019272 bytes
Database Buffers 780140544 bytes
Redo Buffers 5517312 bytes
- 最新评论