Wednesday, May 7, 2008

RMAN switch to COPY

RMAN has a neat feature that allows you to switch the database to run on a backup copy (after recoverying it)

Setup:
-------
In order to set this up you need a datafile copy backup setup in RMAN.
example:
BACKUP FOR RECOVER OF COPY DATAFILECOPY FORMAT='T:\ImageCopies\ORCL\%d_%I_%N_%f' WITH TAG '%d_image_copy' DATABASE;

Make sure T:\ is independent from your current datafile(s) location

SWITCH example (USERS tablespace)
----------------------------------------
Now let's assume we had an i/o error on the file(s) associated with the USERS tablespace and we need to restore ASAP.

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SWITCH TABLESPACE users TO COPY;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";

The above will redirect to the datafile copy, recover it, and bring it online so that the database operates with it.

Now, you probably want to redirect back to the original datafile location at some point. to do so, you would need to perform a new datafile copy backup in RMAN. Here, you would direct the copy to the ORIGINAL datafile location.

Here's an exmaple on how this would be done:
backup as copy datafile 'T:\ImageCopies\ORCL\ORCL_2575401446_USERS_8' format 'D:\oradata/ORCL\USERS_01.dbf';

After that run the same procedure outlined abovve to SWITCH the datafile. Oh, and assuming that all goes well, - take another backup!

No comments:

Post a Comment