show all;
显示rman的默认设置
列出数据库还有那些数据文件需要做备份:
report need backup;
1.已废弃的备份和副本报表(也就是没有用的备份集,是根据rman的冗余来显示的)
report obsolete;
2.显示备份集列表
list backup;
删除过期的备份集
delete backupset n;
如果操作系统中的文件已经删了,而备份信息还在,那么先做crosscheck,然后再delete expired 就可以清除这些不正确的备份信息
crosscheck backuppiece 8;
然后delete backuppiece 8;
物理删除了归档日志,在使用rman 进行备份归档日志的时候出现归档日志不存在
change archivelog all crosscheck;
crosscheck archivelog all;
delete expired archivelog all;
3.恢复spfile
restore spfile to pfile 'e:rmanbkpfile.ora' from autobackup;
4.恢复控制文件:
RMAN> restore controlfile from 'e:rmanbkCF_ORA9_20_1_573229179_20051101';
RMAN> run {
2> restore controlfile to 'e:rmanbkcontrolfilebak.ora' from autobackup;(因为是恢复的是控制文件,所以必须要指定从备份的控制文件中恢复)
3> replicate controlfile from 'e:rmanbkcontrolfilebak.ora';
4> }
5.rman备份的命令格式:
1).分配通道(allocate channel c1 type disk)
2).backup 备份和备份的类型(incremental level=0,1,2,3,4)
3).
4).format 备份集的路径和命令格式
5).备份的内容(database...),(tablespace tools,system....),(archivelog all delete input)
6.对数据库做一次全备份:
run {
allocate channel c1 type disk;
backup incremental level=0
format 'e:rmanbk%d_%p_%t'
(database);
}
run {
allocate channel c1 type disk;
backup full
format 'e:rmanbk%d_%p_%t'
(database);
}
7.备份归档日志:
run {
allocate channel c1 type disk;
backup format 'e:rmanbkarchlog_%d_%p_%t'
(archivelog all);
}
7.备份归档日志(备份之后删除归档日志):
run {
allocate channel c1 type disk;
backup
tag 'ora9_archivelog_2004_11_16'
format 'e:rmanbkarchlog_%d_%p_%t'
(archivelog all delete input);
}
查询那些数据库文件需要进行恢复(在恢复数据文件的时候需要)
select * from v$revocer_file;
select a.name,b.error from v$dbfile a,v$recover_file b where a.file#=b.file#;
恢复整个数据库(也可以使用它恢复数据库中需要恢复的文件)
run {
allocate channel c1 type disk;
restore database;
recover database;
}
恢复某个丢失的数据文件:
run {
allocate channel c1 type disk;
restore datafile 10;
recover datafile 10;
sql "alter database datafile 10 online";
}
恢复某个丢失的数据表空间:
run {
allocate channel c1 type disk;
restore tablespace test;
recover tablespace test;
sql "alter tablespace test online";
}
不完全恢复包括基于时间点、基于SCN、基于Log Sequence的恢复
基于系统变更号的不完全恢复
run {
allocate channel c1 type disk;
set until scn 123456;
restore database;
recover database;
sql "alter database open resetlogs";
}
基于时间不完全恢复
run {
allocate channel c1 type disk;
set until time "TO_DATE('2004-11-22 16:10:54','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
sql "alter database open resetlogs";
}
做基于时间点的恢复
RMAN> run
2> {allocate channel d1 type disk;
3> restore database until time '2005-03-30 16:13:54';
4> recover database;
5> release channel d1;
6> }