Wednesday, April 8, 2009

restore and recover a database to another host with RMAN Backup

1) RMAN> backup database; (source db)

2)Transfer this two backup pieces to target machine from source.

3)Determine the DBID of source machine.

SQL> select dbid from v$database;
( DBA (DBID=1130256874) ERA_h (three Schema database backup) (Personal))

4) Now perform task on target machine
$export ORACLE_SID=dba

Then connect to rman,

$ rman target /

5)Set DBID and restore spfile to pfile.

RMAN> set dbid 3386862614
RMAN> startup nomount
RMAN> restore spfile to pfile '/oracle/app/oracle/product/10.2.0/db_1/dbs/initdbase1.ora' from '/oradata2/o1_mf_s_654016132_421c64vl_.bkp';

6)start the instance with pfile.
RMAN> STARTUP FORCE NOMOUNT PFILE='/oracle/app/oracle/product/10.2.0/db_1/dbs/initdbase1.ora';

7)Restore controlfile and mount the database.RMAN> RESTORE CONTROLFILE FROM '/oradata2/o1_mf_s_654016132_421c64vl_.bkp';
RMAN> ALTER DATABASE MOUNT;

8)From SQL*Plus determine the data file and redo log file name.
SQL> COLUMN NAME FORMAT a70SQL> SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE
UNION
SELECT GROUP#,MEMBER FROM V$LOGFILE ;

9)Catalog your backuppiece.

RMAN> catalog backuppiece '/oradata2/o1_mf_nnndf_TAG20080506T150716_421c355f_.bkp';

RMAN> list backup;

10)Make a script by issuing SET NEWNAME if you want different file name other than source.
In the script issue SET UNTIL clause and restore and recover database.

RMAN> @/export/home/oracle/rman

RMAN> run{
2> set newname for datafile 1 to '/oradata2/DBA/system01.dbf';
3> set newname for datafile 2 to '/oradata2/DBA/undotbs01.dbf';
4> set newname for datafile 3 to '/oradata2/DBA/sysaux01.dbf';
5> set newname for datafile 4 to '/oradata2/DBA/users01.dbf';
6> set newname for datafile 5 to '/oradata2/DBA/tbs201.dbf';
7> set newname for datafile 6 to '/oradata2/DBA/after_01.dbf';
8> set newname for datafile 7 to '/oradata2/DBA/after_02.dbf';
9> set newname for datafile 8 to '/oradata2/DBA/after_03.dbf';
10> set newname for datafile 1 to '/oradata2/DBA/system01.dbf';
11>
12> SET UNTIL SCN 745212;
13> RESTORE DATABASE;
14> SWITCH DATAFILE ALL;
15> RECOVER DATABASE;
16> }


11)Open the Database resetlogs option.
RMAN> alter database open resetlogs;

No comments: