Tuesday 22 November 2011

Restore RMAN full backup to different server with similar directory structure but changed backup location

Restore RMAN full backup to different server with same database name and similar directory structure but changed backup location:


In this article we are going to learn, how to restore RMAN full backup to a different server with same database name and similar directory structure but changed backup location.




 Overview:
This article is a comprehensive guide for restoring RMAN full backup to a different server with same database name and similar directory structure but changed backup location.
Please do keep in mind that this article should not be considered a substitution of the official guide from Oracle (http://www.oracle.com). The below mentioned link can be used to download the official documentation for RMAN Recovery Techniques.
Names used in this article:
 Name  Value
 Database Name  mydb
 Backup Folder on Node1  c:\rman_bck
 Backup Folder on Node2  c:\rman_bck1





Objective of the Article:
By the time we finish this article, we should be able to understand the following:
(1)How to take full backup of database using RMAN.
(2)How to restore RMAN full backup to different server with same database name and similar directory structure but changed backup location.




Connect to the database:
Open command prompt and type the below mentioned:
cmd> set ORACLE_SID=mydb
cmd> sqlplus / as sysdba
Create initialization parameter file (pfile).
sql>create pfile from spfile ;


 For all the screenshots visit the following link::: http://www.sensehaze.com


Take Full Backup of Database using RMAN:
Open command prompt and type the below mentioned:
cmd> rman target /
We can configure the backup location (if not configured earlier). For configuring backup location type the following command:
RMAN> configure channel device type disk format 'C:\rman_bck\mydb_%U' ;



For taking backup of the database, fire the below mentioned command:
RMAN> backup database plus archivelog ;



Copy the required files to the other node:
Copy the below mentioned files to the other node:
--The backup pieces generated using RMAN.
--The initalization parameter file( created above).
--The password file( We can create it also on the other node).


Create similar directory structure on other node:
Create "oradata/mydb" directory on the other node ( for storing controlfiles,datafiles,redo logfiles ). Also create Archive Destination Directory.



Create Service/instance on other node:
Note:This step needs to be performed only on Windows O/S.
Create a service( Here in my case my datbase name -- mydb ).For creating service use "oradim" utility. As mentioned below:
cmd> oradim -new -sid mydb -intpwd sys -startmode manual




Start the database in nomount mode on other node:
Open command prompt and type the below mentioned commands:
cmd> set ORACLE_SID=mydb
cmd> sqlplus / as sysdba
sql> startup nomount pfile='full_path_of_pfile' ;



 For all the screenshots visit the following link:::   http://www.sensehaze.com


 Invoke RMAN on other node:
Open command prompt and type the below mentioned:
cmd> rman target /

Restore Controlfile:
Restore the controlfile from the backup pieces as mentioned below:
RMAN> restore controlfile from 'full_path_control_file_bck_piece' ;

Mount the Database:
After restoring the controlfile from the backuppieces mount the database :
RMAN> alter database mount ;

Crosscheck Backup:
After mounting the database, crosscheck the bakcup, as mentioned below:
RMAN> crosscheck backup ;

Delete Expired Backups:
After running crosscheck, run "delete noprompt expired", as mentioned below:
Note : Be sure we really moved the backup files in the other location, otherwise after entering "delete noprompt expired", these files are lost and we will not able to execute a full restore.
RMAN> delete noprompt expired backup ;

Catalog the Backuppieces:
After running "delete noprompt expired", catalog all the backuppieces, as mentioned below:
RMAN> catalog backuppiece 'full_path_bck_piece_1' ;
RMAN> catalog backuppiece 'full_path_bck_piece_2' ;
RMAN> catalog backuppiece 'full_path_bck_piece_3' ;
RMAN> catalog backuppiece 'full_path_bck_piece_n' ;

Restore Database:
After catalogging all the backuppieces, run restore database command, as mentioned below:
RMAN> restore database ;

Recover Database:
After restoring the database, recover it as mentioned below:
RMAN> recover database ;

If it show error ("media recovery requesting unknown archived log") that means, it requires the new archivelogs, copy the new archivelogs from node1 to node2 and rerurn the above command "recover database". (We can ignore this error).
Open the Database with Resetlogs:
After that, open the database with resetlogs options. As mentioned below:
RMAN> alter database open resetlogs;


Connect to the database & create spfile:
After that, Connect to the database and create spfile. As mentioned below:
cmd> sqlplus / as sysdba
SQL> create spfile from pfile='pfile_location';

This finishes restoring RMAN full backup to a different server with same database name and similar directory structure but changed backup location.
 For all the screenshots visit the following link   :::  http://www.sensehaze.com














No comments:

Post a Comment