Complete Oracle Cold database Restore Routine
After we have seen how we can create a cold backup of our Oracle database using RMAN in this article Complete Oracle Cold Backup Rotine now is time to see how we can restore the database using this cold backup.
For this task you need to follow the steps bellow:
1 - You need to shutdown your database.
connect to rman and run the bellow command.
[ oracle @ TDB ] $ rman target /
Recovery Manager : Release 11 . 2 . 0 . 2 . 0 - Production on Wed Jun 10 12 : 01 : 17 2015
Copyright ( c ) 1982 , 2009 , Oracle and / or its affiliates . All rights reserved .
connected to target database : TDB ( DBID = 3538678151 , open )
RMAN shutdown immediate ;
database closed
database dismounted
Oracle instance shut down
2 - Startup the database in nomount mode
RMAN startup nomount ;
connected to target database ( not started )
Oracle instance started
Total System Global Area 5294772224 bytes
Fixed Size 2235696 bytes
Variable Size 989856464 bytes
Database Buffers 4294967296 bytes
Redo Buffers 7712768 bytes
3 - Restore the control file from the initial backup we took in the first article .
RMAN restore controlfile from '/u00/oradata/TDB/flash_recovery_area/TDB/backupset/bkpset/sp_file_control.bkp' ;
Starting restore at 10-JUN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID = 507 device type = DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete , elapsed time : 00:00:01
output file name = /u00/oradata/TDB/control01.ctl
output file name = /u00/oradata/TDB/control02.ctl
Finished restore at 10-JUN-15
4 - Shutdown and startup the database in mount mode
RMAN shutdown immediate ;
Oracle instance shut down
RMAN startup mount ;
connected to target database ( not started )
Oracle instance started
database mounted
Total System Global Area 5294772224 bytes
Fixed Size 2235696 bytes
Variable Size 989856464 bytes
Database Buffers 4294967296 bytes
Redo Buffers 7712768 bytes
5 - From the RMAN command line CATALOG the backupset.
place the full path to the location of the created backupset from the first article .
RMAN catalog start with '/u00/oradata/TDB/flash_recovery_area/TDB/backupset/backupset' ;
Starting implicit crosscheck backup at 10 - JUN - 15
allocated channel : ORA_DISK_1
channel ORA_DISK_1 : SID = 633 device type = DISK
Crosschecked 5 objects
Finished implicit crosscheck backup at 10 - JUN - 15
Starting implicit crosscheck copy at 10 - JUN - 15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 10 - JUN - 15
searching for all files in the recovery area
cataloging files ...
cataloging done
List of Cataloged Files
=======================
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / sp_file_control . bkp
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / o1_mf_nnndf_TAG20150505T135919_bnl1qwsv_ . bkp
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / o1_mf_nnndf_TAG20150505T135919_bnkxq9kk_ . bkp
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / o1_mf_nnndf_TAG20150505T135919_bnkzr89g_ . bkp
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / o1_mf_nnndf_TAG20150505T135919_bnl0rpms_ . bkp
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / o1_mf_nnndf_TAG20150505T135919_bnkyqs0t_ . bkp
..................
..................
..................
..................
..................
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / autobackup / 2015 _06_09 / o1_mf_s_881938639_bqgm7n7q_ . bkp
searching for all files that match the pattern / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset
List of Files Unknown to the Database
=====================================
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / sp_file_control . bkp
Do you really want to catalog the above files ( enter YES or NO ) ? YES
cataloging files ...
cataloging done
List of Cataloged Files
=======================
File Name : / u00 / oradata / TDB / flash_recovery_area / TDB / backupset / backupset / sp_file_control . bkp
6 - Restore the database.
once the backupset are cataloged we can restore our database.
RMAN restore database ;
Starting restore at 10 - JUN - 15
using channel ORA_DISK_1
channel ORA_DISK_1 : starting datafile backup set restore
channel ORA_DISK_1 : specifying datafile ( s ) to restore from backup set
channel ORA_DISK_1 : restoring datafile 00001 to / u00 / oradata / TDB / system01 . dbf
channel ORA_DISK_1 : restoring datafile 00003 to / u00 / oradata / TDB / undotbs01 . dbf
channel ORA_DISK_1 : restoring datafile 00005 to / u00 / oradata / TDB / TOOLS_01 . dbf
channel ORA_DISK_1 : restoring datafile 00014 to / u00 / oradata / TDB / ACHI03_01 . dbf
channel ORA_DISK_1 : restoring datafile 00016 to / u00 / oradata / TDB / ACHI05_01 . dbf
channel ORA_DISK_1 : restoring datafile 00020 to / u00 / oradata / TDB / ASSD02_01 . dbf
channel ORA_DISK_1 : restoring datafile 00026 to / u00 / oradata / TDB / ASSI04_01 . dbf
....................
....................
....................
To monitor the progress of your RMAN restore you can use this script bellow.
REM RMAN Progress
alter session set nls_date_format = 'dd/mm/yy hh24:mi:ss'
/
select
START_TIME ,
TOTALWORK ,
sofar ,
--(sofar/totalwork) * 100||' %' done,
TO_CHAR (( sofar / totalwork ) * 100 , '99.999' ) || ' %' done ,
sysdate + TIME_REMAINING / 3600 / 24 end_at
from v $ session_longops
where totalwork sofar
AND opname NOT LIKE '%aggregate%'
AND opname like 'RMAN%'
/
START_TIME TOTALWORK SOFAR DONE END_AT
------------------ ------------ -------- -------- ----------------
10 / 06 / 15 11 : 51 : 35 10799758 5147262 47 . 661 % 10 / 06 / 15 12 : 05 : 59
The script will return the progress in % per backup piece so it will reset to 0 every time it starts restoring from a new backup set.
6.1 - The Restore command should return you the following when finished.
channel ORA_DISK_1 : restored backup piece 1
channel ORA_DISK_1 : restore complete , elapsed time : 00 : 14 : 35
Finished restore at 10 - JUN - 15
RMAN
7 - Now we need to connect to the database via SQLPLUS and open it with resetlogs.
[ oracle @ TDB ] $ sqlplus / as sysdba
SQL * Plus : Release 11 . 2 . 0 . 2 . 0 Production on Wed Jun 10 12 : 53 : 14 2015
Copyright ( c ) 1982 , 2010 , Oracle . All rights reserved .
Conectado a :
Oracle Database 11 g Enterprise Edition Release 11 . 2 . 0 . 2 . 0 - 64 bit Production
With the Partitioning , OLAP , Data Mining and Real Application Testing options
alter database open resetlogs ;
Banco de dados alterado .
select status from v $ instance ;
STATUS
------------
OPEN
Great the database was restored using an COLD RMAN backup and the database is up and ready to receive connections.
To get a better idea on how RMAN backups work and what are the types of backup we can take using RMAN see this article
Oracle RMAN Diagram .