Oracle RMAN to Restore and Recover Database to a Previous Incarnation

Subscribe to continue reading

Become a paid subscriber to get access to the rest of this post and other exclusive content.

How to Unregister a Database from RMAN Repository

Target Database is Still Available

You connect to the target database TEST and then unregister it:

rman TARGET SYS/Passwd@TEST CATALOG rman/rman@catdb

RMAN> UNREGISTER DATABASE NOPROMPT;

Unregistering a Database That is Not Unique in Catalog or Target Database is Unvailable

The following UNIX shell script unregisters database testdb from the recovery catalog. Because multiple databases called testdb are registered in the recovery catalog, and because RMAN is not connected to the target database (which has already been deleted from the file system), you must run SET DBID:

Show DBID of a database:

RMAN >  list incarnation of database testdb;
rman CATALOG rman/rman@catdb
RMAN> RUN
{  
  SET DBID 1334531173;   # specifies test database by DBID
  UNREGISTER DATABASE testdb NOPROMPT;
}

List all Registered Database

RMAN > LIST DB_UNIQUE_NAME ALL;

RMAN-06004: Oracle error from recovery catalog database: RMAN-20020: database incarnation not set

The following errors occur when RMAN backup took place:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 08/06/2025 12:38:27
RMAN-03014: implicit resync of recovery catalog failed
RMAN-06004: Oracle error from recovery catalog database: RMAN-20020: database incarnation not set

RESOLUTION

RMAN> reset database;
reset database;
database incarnation already registered

RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous

The following errors occur in the trace file when duplicate a database:

MAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/13/2025 21:01:07
RMAN-05501: aborting duplication of target database
RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous
DBGMISC: ENTERED krmkursr [21:01:13.976]
DBGMISC: EXITED krmkursr [21:01:13.976] elapsed time [00:00:00:00.000]
-------------------------------------------------------------------------------
Trace Bucket Dump End: rman trace

RESOLUTION

If the source database is still running, the run the following the sql to get the dbid:

SQL>  select dbid, name from v$database;

DBID NAME
---------- ---------
1234567890 TESTDB

Otherwise logon to RMAN catalog database, and

SQL>select rbs.db_key
, rd.name
, RBS.DB_ID
, rbs.bs_key
, rbs.recid
, rbs.stamp
, rbs.backup_type
, rbs.start_time, status
from rc_backup_set rbs, rc_database rd
where rbs.db_key=rd.db_key
and rbs.db_id=rd.dbid
and rd.name='TESTDB' ;

DB_KEY NAME DB_ID BS_KEY RECID STAMP B START_TIM S
---------- -------- ---------- ---------- ---------- ---------- - ---------
86602789 TESTDB 1234567890 104349946 5934 1201017848 L 13-MAY-25 A

Finally, in RMAN script add the following:

set dbid=1234567890;
duplicate database from testdb to devdb until time "TO_DATE('2025-05-05 09:00:00','YYYY-MM-DD HH24:MI:SS'

RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous

When trying to duplicate a database, the following RMAN errors occur:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 01/29/2025 16:01:38
RMAN-05501: aborting duplication of target database
RMAN-06004: Oracle error from recovery catalog database: RMAN-20005: target database name is ambiguous

RESOLUTION

RMAN> SET DBID=123456789;
RMAN> DUPLICATE DATABASE....