二、基于恢复目录的备份
1.查看相关信息
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 8 ORCL 1260850162 PARENT 1 30-JUN-05
1 2 ORCL 1260850162 CURRENT 446075 22-OCT-10
----------------------------------------------------------------------------------------------------
RMAN> crosscheck copy; --校验copy
RMAN> delete expired copy; --删除过期的copy
2.全备
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as compressed backupset
4> database plus archivelog delete input
5> format='/u01/app/oracle/bk/rmbk/Whole_%d_%U'
6> tag='Whole_bak';
7> release channel ch1;}
3.增量备份(0级)
RMAN> run{
2> allocate channel ch1 device type disk;
3> allocate channel ch2 device type disk;
4> backup as compressed backupset
5> incremental level 0
6> database plus archivelog delete input
7> format='/u01/app/oracle/bk/rmbk/Inc_0_%d_%U'
8> tag='Inc_0';
9> release channel ch1;
10> release channel ch2;}
RMAN> list backup summary;
4.增量备份(1级)
RMAN> run{
2> allocate channel ch1 device type disk;
3> allocate channel ch2 device type disk;
4> backup as compressed backupset
5> incremental level 1 database
6> format='/u01/app/oracle/bk/rmbk/Inc_1_%d_%U'
7> tag='Inc_1';
8> release channel ch1;
9> release channel ch2;}
RMAN> list backup by file;
5.累计增量备份(1级)
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as compressed backupset
4> incremental level 1 cumulative database
5> format '/u01/app/oracle/bk/rmbk/Cum_1_%d_%U'
6> tag='Cum_1';
7> release channel ch1;}
6.备份表空间
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as compressed backupset
4> tablespace users,example
5> format='/u01/app/oracle/bk/rmbk/tbs_%d_%U'
6> tag='tbs';
RMAN> list backupset tag=tbs;
7.备份数据文件
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as compressed backupset
4> datafile 3
5> format='/u01/app/oracle/bk/rmbk/df_%d_%U'
6> tag='df';
7> release channel ch1;}
8.备份归档日志
备份归档日志前,建议先使用crosscheck校验一下
crosscheck通常用于检查备份是否被删除,如果删除将会打上删除标签
RMAN> crosscheck archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK
validation succeeded for archived log
archive log filename=/u01/app/oracle/oradata/orcl/arch/log_1_117_733069427.arc recid=111 stamp=733171369
Crosschecked 1 objects
RMAN> sql 'alter system switch logfile';
sql statement: alter system switch logfile
RMAN> sql 'alter system switch logfile';
sql statement: alter system switch logfile
RMAN> list archivelog all;
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
465 1 117 A 22-OCT-10 /u01/app/oracle/oradata/orcl/arch/log_1_117_733069427.arc
553 1 118 A 23-OCT-10 /u01/app/oracle/oradata/orcl/arch/log_1_118_733069427.arc
569 1 119 A 23-OCT-10 /u01/app/oracle/oradata/orcl/arch/log_1_119_733069427.arc
9.基于SCN来备份归档日志
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as compressed backupset
4> archivelog from scn 848043
5> format='/u01/app/oracle/bk/rmbk/arc_%d_%U'
6> tag='arc';
7> release channel ch1;
8> }
10.镜像备份
RMAN> run{
2> allocate channel ch1 device type disk;
3> backup as copy datafile 1,4
4> format '/u01/app/oracle/bk/rmbk/df_%d_%U'
5> tag 'copybak';
6> release channel ch1;}
11.其它
RMAN> crosscheck backupset;
RMAN> change backupset 1
RMAN> validate backupset
RMAN> validate backupset 635;
12.基于catalog的数据库恢复请参考:基于catalog 的RMAN 备份与恢复