Oracle · RMAN

RMAN switch to backup copies

The fastest way to restore a datafile is to switch to a copy of the datafile and recover it. Here I will explain how to do it.

If copy of the datafile is your only backup then you will be risking the future recovery operations since you will not have another backup at hand.

SHORT note:

RMAN> backup as copy datafile 15 format '/oradata/newdatafile15.dbf' ;
RMAN> list backup of datafile 15;
RMAN> sql ‘alter database datafile 15 offline’;
RMAN> switch datafile 15 to copy;
RMAN> recover datafile 15 ;
RMAN> sql ‘alter database datafile 15 online’;

LONG note:
RMAN> backup as copy  tablespace users;

Starting backup at 03-MAR-2013 22:14:35
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/test11g/datafile/users.260.804196841
output file name=+FRA/test11g/datafile/users.261.809129675 tag=TAG20130303T221435 RECID=16 STAMP=809129675
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 03-MAR-2013 22:14:36

RMAN> list copy ;

specification does not match any archived log in the repository
List of Datafile Copies
=======================
Key     File S Completion Time      Ckp SCN    Ckp Time
------- ---- - -------------------- ---------- --------------------
16      4    A 03-MAR-2013 22:14:35 690006     03-MAR-2013 22:14:35
        Name: +FRA/test11g/datafile/users.261.809129675
        Tag: TAG20130303T221435

RMAN> sql ‘alter database datafile 4 offline’;

sql statement: alter database datafile 4 offline

RMAN> report schema;

Report of database schema for database with db_unique_name TEST11G

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    700      SYSTEM               ***     +DATA/test11g/datafile/system.256.804196809
2    600      SYSAUX               ***     +DATA/test11g/datafile/sysaux.257.804196819
3    505      UNDOTBS1             ***     +DATA/test11g/datafile/undotbs1.258.804196827
4    5        USERS                ***     +DATA/test11g/datafile/users.260.804196841

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    59       TEMP                 32767       +DATA/test11g/tempfile/temp.259.804196829

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "+FRA/test11g/datafile/users.261.809129675"

RMAN> recover datafile 4 ;

Starting recover at 03-MAR-2013 22:16:21
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 03-MAR-2013 22:16:21

RMAN> sql ‘alter database datafile 4 online’;

sql statement: alter database datafile 4 online

RMAN>  report schema;

Report of database schema for database with db_unique_name TEST11G
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    700      SYSTEM               ***     +DATA/test11g/datafile/system.256.804196809
2    600      SYSAUX               ***     +DATA/test11g/datafile/sysaux.257.804196819
3    505      UNDOTBS1             ***     +DATA/test11g/datafile/undotbs1.258.804196827
4    5        USERS                ***     +FRA/test11g/datafile/users.261.809129675
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    59       TEMP                 32767       +DATA/test11g/tempfile/temp.259.804196829
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s