5 thoughts on “Switch Database to RMAN Image Copy Backup and Switch It Back”

  1. Hi,

    Thank you for a good explanation of this method.

    In scenario #1:

    Shouldn't

    Recover the database:
    SQL> recover database;

    be

    Recover the database:
    RMAN> recover database;

    In my understanding I need to be connected to RMAN to recover, instead of recover the database from sqlprompt.
    In my case I would be connected to a RMAN catalog.

  2. Hi Laurens,

    Thanks for your valuable comment, of course when it comes to database recovery RMAN have advantage over sqlplus. When RMAN recover the database it considers incremental backups and backed up archives inside backupsets, whereas sqlplus doesn't consider backupsets in the recovery process.

  3. Hi, thank you for your reply !

    I have another question:

    A few days back we had to perform the SWITCH DATABASE TO COPY and our database is now running with the copy. We needed to change the DB_RECOVERY_FILE_DEST after that to keep on making RMAN backups.
    Now we are about to switch back the copy (and your procedure is helping bigtime !), so after the "recover database" and "open database" we want to bring down the database again to change the DB_RECOVERY_FILE_DEST back to it's original path in the pfile.
    I assume that is the right way to do it…

    Thank you in advance.

  4. Hi Laurens,

    I didn't think I got your question, but I guess you want to catalog the original database files to RMAN to easily switch back your datafiles from the image copy to the original datafiles, here what you can do:

    Let's suppose you already switched your database to the image backup (which located under DB_RECOVERY_FILE_DEST:

    SQL> select name from v$datafile;

    NAME
    —————————————-
    /backup/flashback/SALES/datafile/o1_mf_system_bfsrlpy2_.dbf
    /backup/flashback/SALES/datafile/o1_mf_sysaux_bfsro27v_.dbf
    /backup/flashback/SALES/datafile/o1_mf_undotbs1_bfsrsbs1_.dbf
    /backup/flashback/SALES/datafile/o1_mf_users_bfsrr6yh_.dbf
    /backup/flashback/SALES/datafile/o1_mf_example_bfsrq3tn_.dbf

    Now you want to switch back to the original datafiles that are located under /database/datafiles/sales
    RMAN gives you the option to catalog those files as a copy backup, so with one switch command your database will switch to them without the need to copy them under DB_RECOVERY_FILE_DEST nor using rename file command:

    RMAN> catalog start with '/database/datafiles/sales/' noprompt;

    you can use "list copy" command to verify cataloged datafiles.

    Now let's switch the database datafiles:

    RMAN> shutdown immediate;
    RMAN> startup mount;
    RMAN> switch database to copy;
    RMAN> recover database;
    RMAN> alter database open;

    SQL> select name from v$datafile;

    NAME
    —————————————
    /database/datafiles/sales/system01.dbf
    /database/datafiles/sales/sysaux01.dbf
    /database/datafiles/sales/undotbs01.dbf
    /database/datafiles/sales/users01.dbf
    /database/datafiles/sales/example01.dbf

    Now datafiles are back.

    Please note that all transactions ran on the database between those switch operations will be recovered from archive logs when you issued "recover database" command, in other word no transactions will be lost in that operation as long as you have all archive logs there.

    I hope that was clear for you.

Leave a Reply

Your email address will not be published. Required fields are marked *