Wednesday, July 1, 2015

12c Steps to restore database from full backup in case of DR

This is a an restore exercise for a CDB database with CDB name.

1. Create INITcdb.ora file with content:

db_name='cdb'

2. Startup database in nomount (it will read the init file and will start the instace)

SQL> startup nomount
ORACLE instance started.

Total System Global Area  234881024 bytes
Fixed Size                  3044152 bytes
Variable Size             176164040 bytes
Database Buffers           50331648 bytes
Redo Buffers                5341184 bytes

3.  Restore SPFILE

In situations requiring the recovery of your SPFILE or control file from autobackup, such as disaster recovery when you have lost all database files, you will need to use your DBID, or you will hit following errors:

RMAN> restore spfile from autobackup;

Starting restore at 01-JUL-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=174 device type=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/01/2015 11:41:26
RMAN-06495: must explicitly specify DBID with SET DBID command

If you do not have a record of the DBID of your database, there are two places you can find it without opening your database.
  • The DBID is used in forming the filename for the control file autobackup. Locate that file and check DBID (IIIIIIIIII) from filename c-IIIIIIIIII-YYYYMMDD-QQ.
  • If you have any text files that preserve the output from an RMAN session, the DBID is displayed by the RMAN client when it starts up and connects to your database.
 RMAN> set dbid=1992057407;

executing command: SET DBID

RMAN> restore spfile from autobackup;

Starting restore at 01-JUL-15
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150701
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150630
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150629
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150628
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150627
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150626
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150625
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/01/2015 11:48:53
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

RMAN> restore spfile from 'E:\app\oracle12c\fast_recovery_area\cdb\AUTOBACKUP\20 15_07_01\O1_MF_S_883904217_BS709BCN_.BKP';

RMAN> shutdown immediate

Oracle instance shut down

RMAN> startup nomount

connected to target database (not started)

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     3047720 bytes
Variable Size               1493176024 bytes
Database Buffers             637534208 bytes
Redo Buffers                  13725696 bytes


4. Restore CONTROLFILES



RMAN> restore controlfile from 'E:\app\oracle12c\fast_recovery_area\cdb\AUTOBACK UP\2015_07_01\O1_MF_S_883904217_BS709BCN_.BKP';

Starting restore at 01-JUL-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=13 device type=DISK

channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/01/2015 11:55:26
ORA-19870: error while restoring backup piece E:\APP\ORACLE12C\FAST_RECOVERY_ARE
A\CDB\AUTOBACKUP\2015_07_01\O1_MF_S_883904217_BS709BCN_.BKP
ORA-19504: failed to create file "E:\APP\ORACLE12C\ORADATA\CDB\CONTROL01.CTL"
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.

NOTE: Create necessary folders before restoring controlfiles


RMAN> restore controlfile from 'E:\app\oracle12c\fast_recovery_area\cdb\AUTOBACK UP\2015_07_01\O1_MF_S_883904217_BS709BCN_.BKP';

Starting restore at 01-JUL-15
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=E:\APP\ORACLE12C\ORADATA\CDB\CONTROL01.CTL
output file name=E:\APP\ORACLE12C\FAST_RECOVERY_AREA\CDB\CONTROL02.CTL
Finished restore at 01-JUL-15

RMAN> alter database mount;

Statement processed

5. Check backups catalogued in controlfiles

RMAN> list backup summary;

6. Restore database (folders of datafiles must be created prior restoring)

RMAN> restore database;

7. Recover database

RMAN> recover database;

8. Open database with resetlogs

RMAN> alter database open resetlogs;

No comments:

Post a Comment