How to have RMAN treat the restored data files like they are originals

migrationoracleoracle-9irestorerman

I am planning a migration for this ancient-but-critical Oracle database from one Windows Server 2003 cluster to another.

The database has many data files and they are all getting new paths on the destination cluster. The only paths that are staying the same are for the backup files.

The migration plan I have is as follows:

  1. Backup the database on the source cluster using our nightly RMAN backup script:

    run {  
        allocate channel Channel1 type disk format 'F:\backup\folder\%d_%T_%s_%U.bak';
        allocate channel Channel2 ... 
    
        backup check logical ( database );
        backup check logical ( archivelog all  not backed up 2 times );
        backup check logical ( current controlfile );
    } 
    
    allocate channel for maintenance device type disk;
    delete archivelog until time 'sysdate - 2' backed up 2 times to disk;
    delete obsolete device type disk;
    

    Our RMAN retention policy on both clusters is set to redundancy 2, and the control file is being used as the recovery catalog.

  2. Copy the backup files to F:\backup\folder on the destination cluster.

  3. Restore the database on the destination cluster using this RMAN script:

    run {
        allocate channel Channel1 type disk;
        allocate channel Channel2 ...
    
        set until sequence <sequence number> thread 1;
    
        SET NEWNAME FOR DATAFILE 'Old\Path\FILE01.DBF' TO 'New\Path\FILE01.DBF';
        SET NEWNAME FOR DATAFILE ...
    
        restore database;
    }
    
  4. Update the data file paths in the control file, recover the database to the appropriate sequence, and open it with resetlogs.

This works great with the following exception:

When I ask RMAN to delete obsolete files on the destination cluster, it names all of the just-restored data files as obsolete!

RMAN> delete obsolete device type disk;
...    
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Datafile Copy        1      02-JUL-12          New\Path\FILE01.DBF
...

Well, RMAN is correct to recognize these data files as copies.

However, since this is a database migration, these copies are intended to be the new originals, so I certainly don't want RMAN to delete them as part of its maintenance!

Is it possible to tweak this migration process so that RMAN treats the restored database as the new original?

Best Answer

Issue switch to copy, then crosscheck.