Oracle RMAN – Why Are Backups Marked Obsolete Without Regard to Redundancy?

oracleoracle-9irman

After incomplete recovery and opening a 9i database with resetlogs we ran a full backup which completed successfully. The backup includes a command to delete obsolete backups after it finishes:

delete noprompt obsolete device type sbt;

RMAN is configured to use REDUNDANCY 2:

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

However all the backups from the old incarnation were immediately marked obsolete and deleted without regard to redundancy.

  1. Would this behaviour have been different if we had a RECOVERY WINDOW configured instead of REDUNDANCY 2?
  2. Is this behaviour the same in later versions of Oracle?

edit: added output of LIST INCARNATION:

RMAN> list incarnation;

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            CUR Reset SCN      Reset Time
------- ------- -------- ---------------- --- -------------- ----------
1       1       LIVE     3494832994       NO  1              19-JAN-04
2       2       LIVE     3494832994       NO  11966702870498 01-JAN-14
3       3       LIVE     3494832994       YES 12041003378277 04-JUL-18

Best Answer

For The Interested RMAN Beginners

The RMAN policies REDUNDANCY and RECOVERY WINDOW are mutually exclusive. This means you can either set one or the other.

Redundancy Policy

Having set REDUNDANCY 2 will always keep only the last two backups and deleting (or marking obsolete) any other previous backups, that are no longer required to bring back the database into a consistent state.

Note:
If you have LEVEL 1 and ARCHIVELOG backups in between the FULL and/or LEVEL 0 backups, then they should be retained until no longer required.

Additional Information

According to the PDF file Oracle Database - Backup and Recovery Reference your retention policy REDUNDANCY 2 should not have deleted your older backups:

The following scenario illustrates how redundancy works in an incremental backup strategy. Assume that the redundancy level is 1. You run a level 0 database backup at noon Monday, a level 1 cumulative backup at noon on Tuesday and Wednesday, and a level 0 backup at noon on Thursday. Immediately after each daily backup you run a DELETE OBSOLETE. The Wednesday DELETE command does not remove the Tuesday level 1 backup because this backup is not redundant: the Tuesday level 1 backup could be used to recover the Monday level 0 backup to a time between noon on Tuesday and noon on Wednesday. However, the DELETE command on Thursday removes the previous level 0 and level 1 backups.

The above example uses a value of 1 but is clearly stating that earlier backups of full backups are not deleted until they are larger than the value configured.

Answering your questions

  1. It depends, .... (see 2. and "Possible Issues")

  2. According to the documentation the retention policy setting still seems to be the same for all versions:

Possible Issues

  • You encountered a bug during the backup and restores of your database instance.

Reproducing with Oracle 12c

Because Oracle RDBMS 9i is pretty much obsolete and our environment is nearly up-to-date, I was only able to re-iterate/reproduce the steps in a 12c environment.

RMAN Configuration

RMAN was set up using the defaults:

RMAN> show all;

RMAN configuration parameters for database with db_unique_name ORACLE12JN are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'C:\ORACLE_12\PRODUCT\12.2.0\DBHOME_1\DATABASE\SNCFORACLE12JN.ORA'; # default

RMAN Backups

RMAN backups were performed by issuing a simple backup database; command:

RMAN> backup database;

Starting backup at 17-JUL-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\ORACLE_12\ORADATA\ORACLE12JN\SYSTEM01.DBF
input datafile file number=00005 name=C:\ORACLE_12\ORADATA\ORACLE12JN\UNDOTBS01.DBF
input datafile file number=00003 name=C:\ORACLE_12\ORADATA\ORACLE12JN\SYSAUX01.DBF
input datafile file number=00007 name=C:\ORACLE_12\ORADATA\ORACLE12JN\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 17-JUL-18
channel ORA_DISK_1: finished piece 1 at 17-JUL-18
piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T151608_FNVV0RH4_.BKP tag=TAG20180717T151608 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 17-JUL-18

Starting Control File and SPFILE Autobackup at 17-JUL-18
piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\AUTOBACKUP\2018_07_17\O1_MF_S_981731783_FNVV17QR_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 17-JUL-18

Verifying Backups, Check Obsolete Backups and List Incarnations

After a certain period of backups had been performed I double-checked the RMAN catalog:

RMAN> list backup summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
3       B  F  A DISK        2018-07-16 10:03:01 1       1       NO         TAG20180716T100301
5       B  F  A DISK        2018-07-16 10:27:44 1       1       NO         TAG20180716T102744
7       B  F  A DISK        2018-07-16 10:49:50 1       1       NO         TAG20180716T104950
9       B  F  A DISK        2018-07-16 10:50:08 1       1       NO         TAG20180716T105007
11      B  F  A DISK        2018-07-16 10:50:22 1       1       NO         TAG20180716T105022
13      B  F  A DISK        2018-07-16 10:51:21 1       1       NO         TAG20180716T105121
15      B  F  A DISK        2018-07-16 13:06:13 1       1       NO         TAG20180716T130612
17      B  F  A DISK        2018-07-16 15:26:23 1       1       NO         TAG20180716T152623
19      B  F  A DISK        2018-07-16 15:57:07 1       1       NO         TAG20180716T155707
20      B  0  A DISK        2018-07-17 08:22:01 1       1       NO         TAG20180717T082154
21      B  F  A DISK        2018-07-17 08:22:02 1       1       NO         TAG20180717T082202
22      B  0  A DISK        2018-07-17 14:36:07 1       1       NO         TAG20180717T143558
23      B  F  A DISK        2018-07-17 14:36:14 1       1       NO         TAG20180717T143614
24      B  F  A DISK        2018-07-17 15:16:15 1       1       NO         TAG20180717T151608
25      B  F  A DISK        2018-07-17 15:16:23 1       1       NO         TAG20180717T151623
26      B  A  A DISK        2018-07-17 15:55:52 1       1       NO         TAG20180717T155551
27      B  F  A DISK        2018-07-17 15:55:53 1       1       NO         TAG20180717T155553
28      B  F  A DISK        2018-07-17 16:05:17 1       1       NO         TAG20180717T160517

Verified that no obsolete backups were lying around:

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
no obsolete backups found

RMAN>

And listed the current incarnations:

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORACLE12 2083073378       PARENT  1          2017-03-08 15:57:31
2       2       ORACLE12 2083073378       CURRENT 1490582    2018-07-16 09:27:03

Perform First Restore / Recovery

The following commands were issued to restore/recover the database into a consistent state:

RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1610612736 bytes

Fixed Size                     8747368 bytes
Variable Size                385877656 bytes
Database Buffers            1207959552 bytes
Redo Buffers                   8028160 bytes

RMAN> run
2> {
3> set until time '2018-07-17 14:36:14';
4> restore database;
5> recover database;
6> }

executing command: SET until clause

Starting restore at 2018-07-17 16:04:30
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to C:\ORACLE_12\ORADATA\ORACLE12JN\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00003 to C:\ORACLE_12\ORADATA\ORACLE12JN\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00005 to C:\ORACLE_12\ORADATA\ORACLE12JN\UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00007 to C:\ORACLE_12\ORADATA\ORACLE12JN\USERS01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T143558_FNVROH49_.BKP
channel ORA_DISK_1: piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T143558_FNVROH49_.BKP tag=TAG20180717T143558
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018-07-17 16:04:38

Starting recover at 2018-07-17 16:04:38
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 2018-07-17 16:04:39

RMAN> alter database open resetlogs;

Statement processed

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORACLE12 2083073378       PARENT  1          2017-03-08 15:57:31
2       2       ORACLE12 2083073378       PARENT  1490582    2018-07-16 09:27:03
3       3       ORACLE12 2083073378       CURRENT 1701490    2018-07-17 16:05:13

RMAN> list backup summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
3       B  F  A DISK        2018-07-16 10:03:01 1       1       NO         TAG20180716T100301
5       B  F  A DISK        2018-07-16 10:27:44 1       1       NO         TAG20180716T102744
7       B  F  A DISK        2018-07-16 10:49:50 1       1       NO         TAG20180716T104950
9       B  F  A DISK        2018-07-16 10:50:08 1       1       NO         TAG20180716T105007
11      B  F  A DISK        2018-07-16 10:50:22 1       1       NO         TAG20180716T105022
13      B  F  A DISK        2018-07-16 10:51:21 1       1       NO         TAG20180716T105121
15      B  F  A DISK        2018-07-16 13:06:13 1       1       NO         TAG20180716T130612
17      B  F  A DISK        2018-07-16 15:26:23 1       1       NO         TAG20180716T152623
19      B  F  A DISK        2018-07-16 15:57:07 1       1       NO         TAG20180716T155707
20      B  0  A DISK        2018-07-17 08:22:01 1       1       NO         TAG20180717T082154
21      B  F  A DISK        2018-07-17 08:22:02 1       1       NO         TAG20180717T082202
22      B  0  A DISK        2018-07-17 14:36:07 1       1       NO         TAG20180717T143558
23      B  F  A DISK        2018-07-17 14:36:14 1       1       NO         TAG20180717T143614
24      B  F  A DISK        2018-07-17 15:16:15 1       1       NO         TAG20180717T151608
25      B  F  A DISK        2018-07-17 15:16:23 1       1       NO         TAG20180717T151623
26      B  A  A DISK        2018-07-17 15:55:52 1       1       NO         TAG20180717T155551
27      B  F  A DISK        2018-07-17 15:55:53 1       1       NO         TAG20180717T155553
28      B  F  A DISK        2018-07-17 16:05:17 1       1       NO         TAG20180717T160517

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
no obsolete backups found

The restore was successful and no backups were marked as obsolete even though the incarnation changed after the restore and with the ALTER DATABASE OPEN RESETLOGS issued.

Alternate Incarnation Listing

An alternate representation of the incarnations can be achieved with the following command:

alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
set pages 50
set lines 230
column Path format a20
select INCARNATION#, RESETLOGS_CHANGE#, RESETLOGS_TIME, 
PRIOR_INCARNATION#, STATUS, LEVEL, SYS_CONNECT_BY_PATH(INCARNATION#, ' -> ') Path 
from v$database_incarnation 
WHERE LEVEL >=1 START WITH INCARNATION# = '1' 
CONNECT BY PRIOR INCARNATION# = PRIOR_INCARNATION# 
order by Level, Path, RESETLOGS_TIME;

Output:

INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      PRIOR_INCARNATION# STATUS       LEVEL PATH
------------ ----------------- ------------------- ------------------ ------- ---------- --------------------
           1                 1 2017-03-08 15:57:31                  0 PARENT           1  -> 1
           2           1490582 2018-07-16 09:27:03                  1 PARENT           2  -> 1 -> 2
           3           1701490 2018-07-17 16:05:13                  2 CURRENT          3  -> 1 -> 2 -> 3

The advantage of querying the local catalog in the database instance is the representation of the incarnation as a path to follow

Perform Second Restore / Recovery

The following commands were issued to restore/recover the database into a consistent state again:

RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1610612736 bytes

Fixed Size                     8747368 bytes
Variable Size                520095384 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   8028160 bytes

RMAN> run
2> {
3> set until time '2018-07-17 08:22:01';
4> restore database;
5> recover database;
6> }

executing command: SET until clause

Starting restore at 2018-07-17 16:14:37
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/17/2018 16:14:37
RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

Ok, we've hit an incarnation "bump" in the restore path. We are currently on incarnation 3 as can be seen in the incarnation listing below which I copied from above:

INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      PRIOR_INCARNATION# STATUS       LEVEL PATH
------------ ----------------- ------------------- ------------------ ------- ---------- --------------------
           1                 1 2017-03-08 15:57:31                  0 PARENT           1  -> 1
           2           1490582 2018-07-16 09:27:03                  1 PARENT           2  -> 1 -> 2
           3           1701490 2018-07-17 16:05:13                  2 CURRENT          3  -> 1 -> 2 -> 3

...and the backup we are aiming for is after the RESETLOGS for incarnation 2. Let's reset the incarnation to 2 and proceed with the backup:

RMAN> reset database to incarnation 2;

database reset to incarnation 2

RMAN>

Seems to work. Let's restart the restore/recover again:

RMAN> run
2> {
3> set until time '2018-07-17 08:22:01';
4> restore database;
5> recover database;
6> }

executing command: SET until clause

Starting restore at 2018-07-17 16:16:12
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to C:\ORACLE_12\ORADATA\ORACLE12JN\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00003 to C:\ORACLE_12\ORADATA\ORACLE12JN\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00005 to C:\ORACLE_12\ORADATA\ORACLE12JN\UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00007 to C:\ORACLE_12\ORADATA\ORACLE12JN\USERS01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T082154_FNV2R328_.BKP
channel ORA_DISK_1: piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T082154_FNV2R328_.BKP tag=TAG20180717T082154
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018-07-17 16:16:20

Starting recover at 2018-07-17 16:16:20
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_3_FNVXC7R7_.ARC
archived log file name=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_3_FNVXC7R7_.ARC thread=1 sequence=3
media recovery complete, elapsed time: 00:00:00
Finished recover at 2018-07-17 16:16:21

RMAN> alter database open resetlogs;

Statement processed

RMAN> report obsolete
2> ;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
no obsolete backups found

RMAN>

The restore was successful and no backups were marked as obsolete even though the incarnation changed after the restore and the ALTER DATABASE OPEN RESETLOGS was issued again. Now we are on a newer incarnation and still no Obsolete Backups reported.

List of Current Incarnations After Second Restore (SQL)

SQL> select INCARNATION#, RESETLOGS_CHANGE#, RESETLOGS_TIME, PRIOR_INCARNATION#, STATUS, LEVEL, SYS_CONNECT_BY_PATH(INCARNATION#, ' -> ') Path from v$database_incarnation WHERE LEVEL >=1 START WITH INCARNATION# = '1' CONNECT BY PRIOR INCARNATION# = PRIOR_INCARNATION# order by Level, Path, RESETLOGS_TIME;

INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      PRIOR_INCARNATION# STATUS       LEVEL PATH
------------ ----------------- ------------------- ------------------ ------- ---------- --------------------
           1                 1 2017-03-08 15:57:31                  0 PARENT           1  -> 1
           2           1490582 2018-07-16 09:27:03                  1 PARENT           2  -> 1 -> 2
           3           1701490 2018-07-17 16:05:13                  2 ORPHAN           3  -> 1 -> 2 -> 3
           4           1691865 2018-07-17 16:16:29                  2 CURRENT          3  -> 1 -> 2 -> 4

Initiate Backup

After restoring the second time let's backup the database again:

RMAN> backup database;

Starting backup at 2018-07-17 16:51:39
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\ORACLE_12\ORADATA\ORACLE12JN\SYSTEM01.DBF
input datafile file number=00005 name=C:\ORACLE_12\ORADATA\ORACLE12JN\UNDOTBS01.DBF
input datafile file number=00003 name=C:\ORACLE_12\ORADATA\ORACLE12JN\SYSAUX01.DBF
input datafile file number=00007 name=C:\ORACLE_12\ORADATA\ORACLE12JN\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 2018-07-17 16:51:39
channel ORA_DISK_1: finished piece 1 at 2018-07-17 16:51:46
piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T165139_FNW0MVRT_.BKP tag=TAG20180717T165139 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 2018-07-17 16:51:46

Starting Control File and SPFILE Autobackup at 2018-07-17 16:51:46
piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\AUTOBACKUP\2018_07_17\O1_MF_S_981737506_FNW0N31S_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 2018-07-17 16:51:47

RMAN>

Check Obsolete

We'll now check which (backup) files have become obsolete:

RMAN> report obsolete
2> ;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           20     2018-07-17 08:22:01
  Backup Piece       20     2018-07-17 08:22:01 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T082154_FNV2R328_.BKP
Backup Set           22     2018-07-17 14:36:07
  Backup Piece       22     2018-07-17 14:36:07 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T143558_FNVROH49_.BKP
Backup Set           24     2018-07-17 15:16:15
  Backup Piece       24     2018-07-17 15:16:15 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T151608_FNVV0RH4_.BKP
Archive Log          2      2018-07-17 15:55:51 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_3_FNVXC7R7_.ARC
Backup Set           26     2018-07-17 15:55:52
  Backup Piece       26     2018-07-17 15:55:52 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_ANNNN_TAG20180717T155551_FNVXC84F_.BKP
Archive Log          3      2018-07-17 16:05:13 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_4_FNVXWSDY_.ARC

RMAN>

Check Incarnations (SQL)

SQL> select INCARNATION#, RESETLOGS_CHANGE#, RESETLOGS_TIME, PRIOR_INCARNATION#, STATUS, LEVEL, SYS_CONNECT_BY_PATH(INCARNATION#, ' -> ') Path from v$database_incarnation WHERE LEVEL >=1 START WITH INCARNATION# = '1' CONNECT BY PRIOR INCARNATION# = PRIOR_INCARNATION# order by Level, Path, RESETLOGS_TIME;

INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      PRIOR_INCARNATION# STATUS       LEVEL PATH
------------ ----------------- ------------------- ------------------ ------- ---------- --------------------
           1                 1 2017-03-08 15:57:31                  0 PARENT           1  -> 1
           2           1490582 2018-07-16 09:27:03                  1 PARENT           2  -> 1 -> 2
           3           1701490 2018-07-17 16:05:13                  2 ORPHAN           3  -> 1 -> 2 -> 3
           4           1691865 2018-07-17 16:16:29                  2 CURRENT          3  -> 1 -> 2 -> 4

As can be seen the incarnation 3 is now orphaned, because its direct line of heritage in regards to the current state of the database is broken. After the first restore we went back in time an re-restored the database again which results in the incarnation path 1 -> 2 -> 4 being the direct line of current ancestors for the open database.

Because the direct line for restoring the current database is along the incarnations of 1, 2, 4 there is no need for RMAN to keep the obsolete backups listed above. They can safely be deleted.

Delete Obsolete

Let's go ahead and delete the obsolete backups:

RMAN> delete obsolete
2> ;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           20     2018-07-17 08:22:01
  Backup Piece       20     2018-07-17 08:22:01 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T082154_FNV2R328_.BKP
Backup Set           22     2018-07-17 14:36:07
  Backup Piece       22     2018-07-17 14:36:07 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T143558_FNVROH49_.BKP
Backup Set           24     2018-07-17 15:16:15
  Backup Piece       24     2018-07-17 15:16:15 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T151608_FNVV0RH4_.BKP
Archive Log          2      2018-07-17 15:55:51 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_3_FNVXC7R7_.ARC
Backup Set           26     2018-07-17 15:55:52
  Backup Piece       26     2018-07-17 15:55:52 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_ANNNN_TAG20180717T155551_FNVXC84F_.BKP
Archive Log          3      2018-07-17 16:05:13 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_4_FNVXWSDY_.ARC
Backup Set           30     2018-07-17 16:17:52
  Backup Piece       30     2018-07-17 16:17:52 C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T161743_FNVYN815_.BKP

Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T082154_FNV2R328_.BKP RECID=20 STAMP=981706915
deleted backup piece
backup piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNND0_TAG20180717T143558_FNVROH49_.BKP RECID=22 STAMP=981729359
deleted backup piece
backup piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T151608_FNVV0RH4_.BKP RECID=24 STAMP=981731768
deleted archived log
archived log file name=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_3_FNVXC7R7_.ARC RECID=2 STAMP=981734151
deleted backup piece
backup piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_ANNNN_TAG20180717T155551_FNVXC84F_.BKP RECID=26 STAMP=981734152
deleted archived log
archived log file name=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\ARCHIVELOG\2018_07_17\O1_MF_1_4_FNVXWSDY_.ARC RECID=3 STAMP=981734713
deleted backup piece
backup piece handle=C:\ORACLE_12\RECOVERY_AREA\ORACLE12JN\BACKUPSET\2018_07_17\O1_MF_NNNDF_TAG20180717T161743_FNVYN815_.BKP RECID=30 STAMP=981735464
Deleted 7 objects

List Backup Summary

Now that we have deleted some backup files and RMAN has performed some internal cleaning, let's have a look at the backup summary:

RMAN> list backup summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
3       B  F  A DISK        2018-07-16 10:03:01 1       1       NO         TAG20180716T100301
5       B  F  A DISK        2018-07-16 10:27:44 1       1       NO         TAG20180716T102744
7       B  F  A DISK        2018-07-16 10:49:50 1       1       NO         TAG20180716T104950
9       B  F  A DISK        2018-07-16 10:50:08 1       1       NO         TAG20180716T105007
11      B  F  A DISK        2018-07-16 10:50:22 1       1       NO         TAG20180716T105022
13      B  F  A DISK        2018-07-16 10:51:21 1       1       NO         TAG20180716T105121
15      B  F  A DISK        2018-07-16 13:06:13 1       1       NO         TAG20180716T130612
17      B  F  A DISK        2018-07-16 15:26:23 1       1       NO         TAG20180716T152623
19      B  F  A DISK        2018-07-16 15:57:07 1       1       NO         TAG20180716T155707
21      B  F  A DISK        2018-07-17 08:22:02 1       1       NO         TAG20180717T082202
23      B  F  A DISK        2018-07-17 14:36:14 1       1       NO         TAG20180717T143614
25      B  F  A DISK        2018-07-17 15:16:23 1       1       NO         TAG20180717T151623
27      B  F  A DISK        2018-07-17 15:55:53 1       1       NO         TAG20180717T155553
28      B  F  A DISK        2018-07-17 16:05:17 1       1       NO         TAG20180717T160517
29      B  F  A DISK        2018-07-17 16:16:34 1       1       NO         TAG20180717T161634
31      B  F  A DISK        2018-07-17 16:17:59 1       1       NO         TAG20180717T161759
32      B  F  A DISK        2018-07-17 16:51:46 1       1       NO         TAG20180717T165139
33      B  F  A DISK        2018-07-17 16:51:47 1       1       NO         TAG20180717T165146
34      B  F  A DISK        2018-07-18 07:24:13 1       1       NO         TAG20180718T072405
35      B  F  A DISK        2018-07-18 07:24:21 1       1       NO         TAG20180718T072421

RMAN>

As we can see we still have "at least" two complete backup that will allow us to restore the database two backups in the past. RMAN (in 12c) did not delete any other backups along the incarnation path or outside of the orphaned incarnation.

Conclusion

Regarding the deleted backups after your initial restore in 9i I believe there are two possible scenarios:

  1. You hit a bug.
  2. After the restore two (FULL) backups were initiated which resulted in the backups being deleted on tape.

Reference Material

  • Doc ID 206862.1 (How does the RMAN Retention Policy Obsolete Incremental Backupsets and Archivelog Files)
    • Valid for Oracle 9i+