DEV Community

Vahid Yousefzadeh
Vahid Yousefzadeh

Posted on

Restoring a Lost Datafile from Standby Using RMAN

If an operating system–level datafile is lost in the primary database environment, this loss can be compensated using the existing datafile on the Data Guard server (provided that the files are compatible).

In versions prior to 12c, the DBA needed to manually transfer the datafile from the Data Guard environment to the primary database at the OS level.

In 12c, this task can be performed using a single RMAN command:
— Primary:

SQL> create tablespace tbs1 datafile ‘/u01/test1.dbf’ size 10m;

SQL> !mv /u01/test1.dbf  /u01/test2.dbf
Enter fullscreen mode Exit fullscreen mode
rman target /
RMAN> RESTORE DATAFILE  ‘/u01/test1.dbf’ FROM SERVICE stb;



Starting restore at 05-JUL-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=4 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: using network backup set from service stb

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00005 to /u01/test1.dbf

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 05-JUL-16
Enter fullscreen mode Exit fullscreen mode

Note: In this command, you can use the datafile number instead of its name:

RMAN>  RESTORE DATAFILE  5  FROM SERVICE  stb;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)