原文转自:http://jiujian.blog.51cto.com/444665/1165766
Lists full backups, data file copies, and archived redo log files recorded in the
RMAN repository that can be deleted because they are no longer needed The command works
in two steps:
For each data file that has been backed up, RMAN identifies the oldest full
backup, level 0 backup, or image copy that is not obsolete under the
retention policy. Any backup of the data file older than the one identified in
this step is considered obsolete.
Any archived redo log files and level 1 incremental backups that are older
than the oldest nonobsolete full backup are considered obsolete. These files
are obsolete because no full or level 0 backup exists to which they can be
applied. Incremental level 1 backups or archived redo log files are not
considered obsolete if they can be applied to nonobsolete level 0 or full
backups.
第一段:
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name CRM are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
no obsolete backups found
RMAN> run{
2> allocate channel c1 type disk;
3> backup archivelog all format '/backup/arch2_%T_%U';
4> release channel c1;
5> }
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:15:47
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=124 RECID=843 STAMP=811181727
input archived log thread=1 sequence=125 RECID=844 STAMP=811181727
input archived log thread=1 sequence=126 RECID=845 STAMP=811181728
input archived log thread=1 sequence=127 RECID=846 STAMP=811181729
input archived log thread=1 sequence=128 RECID=847 STAMP=811181729
input archived log thread=1 sequence=129 RECID=848 STAMP=811181730
input archived log thread=1 sequence=130 RECID=849 STAMP=811181747
channel c1: starting piece 1 at 2013-03-27 16:15:48
channel c1: finished piece 1 at 2013-03-27 16:15:49
piece handle=/backup/arch2_20130327_0mo5j9lj_1_1 tag=TAG20130327T161547 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2013-03-27 16:15:49
Starting Control File and SPFILE Autobackup at 2013-03-27 16:15:49
piece handle=/backup/c-3599153036-20130327-04 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:15:50
released channel: c1
RMAN> run{
2> allocate channel c1 type disk;
3> backup archivelog all format '/backup/arch2_%T_%U';
4> release channel c1;
5> }
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:15:56
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=124 RECID=843 STAMP=811181727
input archived log thread=1 sequence=125 RECID=844 STAMP=811181727
input archived log thread=1 sequence=126 RECID=845 STAMP=811181728
input archived log thread=1 sequence=127 RECID=846 STAMP=811181729
input archived log thread=1 sequence=128 RECID=847 STAMP=811181729
input archived log thread=1 sequence=129 RECID=848 STAMP=811181730
input archived log thread=1 sequence=130 RECID=849 STAMP=811181747
input archived log thread=1 sequence=131 RECID=850 STAMP=811181756
channel c1: starting piece 1 at 2013-03-27 16:15:56
channel c1: finished piece 1 at 2013-03-27 16:15:57
piece handle=/backup/arch2_20130327_0oo5j9ls_1_1 tag=TAG20130327T161556 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2013-03-27 16:15:57
Starting Control File and SPFILE Autobackup at 2013-03-27 16:15:57
piece handle=/backup/c-3599153036-20130327-05 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:15:58
released channel: c1
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 838 2013-03-27 16:09:54
Backup Piece 847 2013-03-27 16:09:54 /backup/c-3599153036-20130327-03
Backup Set 840 2013-03-27 16:15:50
Backup Piece 849 2013-03-27 16:15:50 /backup/c-3599153036-20130327-04
RMAN> run{
2> allocate channel c1 type disk;
3> backup database format '/backup/fulldb_%T_%U';
4> release channel c1;
5> }
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:16:58
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=/oracle/CRM/test2/USERS4.dbf
input datafile file number=00001 name=/oracle/CRM/test2/SYSTEM1.dbf
input datafile file number=00002 name=/oracle/CRM/test2/SYSAUX2.dbf
input datafile file number=00005 name=/oracle/CRM/test2/pos1.dbf
input datafile file number=00003 name=/oracle/CRM/test2/UNDOTBS33.dbf
input datafile file number=00006 name=/oracle/CRM/test2/ERP6.dbf
input datafile file number=00009 name=/oracle/CRM/test2/pos2.dbf
input datafile file number=00007 name=/oracle/CRM/test2/USER017.dbf
input datafile file number=00008 name=/oracle/CRM/test2/TEST8.dbf
channel c1: starting piece 1 at 2013-03-27 16:16:58
channel c1: finished piece 1 at 2013-03-27 16:19:43
piece handle=/backup/fulldb_20130327_0qo5j9nq_1_1 tag=TAG20130327T161658 comment=NONE
channel c1: backup set complete, elapsed time: 00:02:46
Finished backup at 2013-03-27 16:19:44
Starting Control File and SPFILE Autobackup at 2013-03-27 16:19:44
piece handle=/backup/c-3599153036-20130327-06 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:19:47
released channel: c1
SQL> select group#,archived,sequence#,status from v$Log;
GROUP# ARC SEQUENCE# STATUS
---------- --- ---------- ----------------
1 YES 129 INACTIVE
2 YES 130 INACTIVE
3 YES 131 INACTIVE
4 NO 132 CURRENT
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 837 2013-03-27 16:09:48
Backup Piece 846 2013-03-27 16:09:48 /backup/fulldb1_20130327_0ho5j95g_1_1
Archive Log 844 2013-03-27 16:15:27 /oracle/archive/1_125_810495590.dbf
Backup Set 838 2013-03-27 16:09:54
Backup Piece 847 2013-03-27 16:09:54 /backup/c-3599153036-20130327-03
Archive Log 843 2013-03-27 16:15:27 /oracle/archive/1_124_810495590.dbf
Archive Log 845 2013-03-27 16:15:28 /oracle/archive/1_126_810495590.dbf
Archive Log 846 2013-03-27 16:15:29 /oracle/archive/1_127_810495590.dbf
Archive Log 847 2013-03-27 16:15:29 /oracle/archive/1_128_810495590.dbf
Archive Log 848 2013-03-27 16:15:30 /oracle/archive/1_129_810495590.dbf
Archive Log 849 2013-03-27 16:15:47 /oracle/archive/1_130_810495590.dbf
Backup Set 839 2013-03-27 16:15:48
Backup Piece 848 2013-03-27 16:15:48 /backup/arch2_20130327_0mo5j9lj_1_1
Backup Set 840 2013-03-27 16:15:50
Backup Piece 849 2013-03-27 16:15:50 /backup/c-3599153036-20130327-04
Archive Log 850 2013-03-27 16:15:56 /oracle/archive/1_131_810495590.dbf
Backup Set 841 2013-03-27 16:15:56
Backup Piece 850 2013-03-27 16:15:56 /backup/arch2_20130327_0oo5j9ls_1_1
Backup Set 842 2013-03-27 16:15:58
Backup Piece 851 2013-03-27 16:15:58 /backup/c-3599153036-20130327-05