Oracle Recovery Manager (RMAN) provides a comprehensive foundation for efficiently backing up and recovering the Oracle databases, it provides a common interface, via command line and Enterprise Manager, for backup tasks across different host operating systems, automates administration of your backup strategies.
Backup-based duplication uses an RMAN backup of the target (source) database as its source to create the data files in the auxiliary (destination) environment.
No connection to the target database is required. This is referred to as targetless duplication. This technique only requires a connection to the auxiliary database. Targetless duplication is available in Oracle 11g release 2 and higher.
The big advantage to backup based duplication is that if you work in an environment where it’s not possible to have a simultaneous connection to both the target and the auxiliary database you can still duplicate a database provided you can copy an RMAN backup to the auxiliary database
Server (or provided the backup is on network-mounted storage readable from the auxiliary server). In many environments, due to security rules, there is no network connectivity allowed from test environments to the production server.
In this scenario we have same database name and same directory structure.
Environment Details
|
Database Name
|
prod
|
|
Hostname
|
Nsmprod
|
|
Ip Address
|
172.16.110.18
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod
|
|
Backup Location
|
/backup/rman_backup
|
|
Database Name
|
prod
|
|
Hostname
|
Nsmstg
|
|
Ip Address
|
172.16.110.16
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod
|
|
Backup Location
|
/backup/rman_backup
|
Pre-requisites:
- Password file from target database.
- Sqlnet.ora should have correct parameters.
- Target database should be running through spfile.
Steps on target (source) server:
1. export Oracle sid.
hostname
ORACLE_SID=prod
2. Connect to target database via RMAN.
target sys/oracle
11.2.0.1.0 – Production on Thu Apr 9 10:47:41 2015
Oracle and/or its affiliates. All rights
reserved.
database: PROD (DBID=284539893)
3. Issue the following command to initiate backup. Before issue the backup command check the backup location is sat correctly.
parameters for database with db_unique_name PROD are:
TO REDUNDANCY 1; # default
OPTIMIZATION OFF; # default
TYPE TO DISK; # default
AUTOBACKUP ON;
CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
‘/backup/rman_backup/controlfile_%F’;
PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
COPIES FOR DEVICE TYPE DISK TO 1; # default
COPIES FOR DEVICE TYPE DISK TO 1; # default
CHANNEL DEVICE TYPE DISK FORMAT
‘/backup/rman_backup/db_arch_%U.bkp’;
UNLIMITED; # default
DATABASE OFF; # default
ALGORITHM ‘AES128’; # default
ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
DELETION POLICY TO NONE; # default
CONTROLFILE NAME TO ‘/data2/app/oracle/product/11.2.0/dbs/snapcf_prod.f’; #
default
any backup in the repository
backup database plus archivelog;
archived log backup set
specifying archived log(s) in backup set
sequence=90 RECID=86 STAMP=875202890
sequence=91 RECID=87 STAMP=875225400
sequence=92 RECID=88 STAMP=875253619
sequence=93 RECID=89 STAMP=875287426
sequence=94 RECID=90 STAMP=875311887
sequence=95 RECID=91 STAMP=875338210
sequence=96 RECID=92 STAMP=875371700
sequence=97 RECID=93 STAMP=875398375
sequence=98 RECID=94 STAMP=875422534
sequence=99 RECID=95 STAMP=875455916
sequence=100 RECID=96 STAMP=875489442
sequence=101 RECID=97 STAMP=875511892
sequence=102 RECID=98 STAMP=875532973
sequence=103 RECID=99 STAMP=875566589
sequence=104 RECID=100 STAMP=875598381
sequence=105 RECID=101 STAMP=875617253
sequence=106 RECID=102 STAMP=875650222
sequence=107 RECID=103 STAMP=875683804
sequence=108 RECID=104 STAMP=875692844
sequence=109 RECID=105 STAMP=875726521
sequence=110 RECID=106 STAMP=875759423
sequence=111 RECID=107 STAMP=875771364
sequence=112 RECID=108 STAMP=875804400
sequence=113 RECID=109 STAMP=875809288
sequence=114 RECID=110 STAMP=875842252
sequence=115 RECID=111 STAMP=875857844
sequence=116 RECID=112 STAMP=875883160
sequence=117 RECID=113 STAMP=875939543
sequence=118 RECID=114 STAMP=875955632
sequence=119 RECID=115 STAMP=875960595
sequence=120 RECID=116 STAMP=876018651
sequence=121 RECID=117 STAMP=876036137
sequence=122 RECID=118 STAMP=876094207
sequence=123 RECID=119 STAMP=876117455
sequence=124 RECID=120 STAMP=876173429
sequence=125 RECID=121 STAMP=876203937
sequence=126 RECID=122 STAMP=876259857
sequence=127 RECID=123 STAMP=876288622
sequence=128 RECID=124 STAMP=876308432
sequence=129 RECID=125 STAMP=876364250
sequence=130 RECID=126 STAMP=876378605
sequence=131 RECID=127 STAMP=876398550
sequence=132 RECID=128 STAMP=876399532
sequence=133 RECID=129 STAMP=876419413
sequence=134 RECID=130 STAMP=876421079
sequence=135 RECID=131 STAMP=876461598
sequence=136 RECID=132 STAMP=876504610
sequence=137 RECID=133 STAMP=876548085
sequence=138 RECID=134 STAMP=876567056
sequence=139 RECID=135 STAMP=876567230
sequence=140 RECID=136 STAMP=876583581
sequence=141 RECID=137 STAMP=876583754
sequence=142 RECID=138 STAMP=876586722
sequence=143 RECID=139 STAMP=876586874
sequence=144 RECID=140 STAMP=876641790
sequence=145 RECID=141 STAMP=876670700
piece 1 at 10-APR-15
piece 1 at 10-APR-15
handle=/backup/rman_backup/db_arch_2qq41rnc_1_1.bkp tag=TAG20150410T153820
comment=NONE
set complete, elapsed time: 00:01:35
full datafile backup set
specifying datafile(s) in backup set
number=00001 name=/data2/prod/system01.dbf
number=00002 name=/data2/prod/sysaux01.dbf
number=00005 name=/data2/prod/example01.dbf
number=00003 name=/data2/prod/undotbs01.dbf
number=00006 name=/data2/prod/data01.dbf
number=00004 name=/data2/prod/users01.dbf
number=00007 name=/data2/prod/test01.dbf
number=00008 name=/data2/prod/tools01.dbf
piece 1 at 10-APR-15
piece 1 at 10-APR-15
tag=TAG20150410T153956 comment=NONE
set complete, elapsed time: 00:01:05
archived log backup set
specifying archived log(s) in backup set
sequence=146 RECID=142 STAMP=876670863
piece 1 at 10-APR-15
piece 1 at 10-APR-15
handle=/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp tag=TAG20150410T154103
comment=NONE
set complete, elapsed time: 00:00:01
SPFILE Autobackup at 10-APR-15
handle=/backup/rman_backup/controlfile_c-284539893-20150410-00 comment=NONE
SPFILE Autobackup at 10-APR-15
4. Create pfile and copy to destination server.
pfile=’/backup/rman_backup/initprod.ora’ from spfile;
rman_backup]$ scp initprod.ora
oracle@172.16.110.16:/data1/oracle11g/product/dbs/
password:
00:00
create directory structure to accommodate rman backup pieces on destination server and start copy.
-p /backup/rman_backup/
5. Copy rman backup from target to destination server.
rman_backup]$ ls -lrth
1.7G Apr 10 15:39 db_arch_2qq41rnc_1_1.bkp
Apr 10 15:40 db_arch_2rq41rqd_1_1.bkp
dba 24K Apr 10 15:41
db_arch_2sq41rsf_1_1.bkp
9.6M Apr 10 15:41 controlfile_c-284539893-20150410-00
rman_backup]$ scp * oracle@172.16.110.16:/backup/rman_backup/
password:
00:01
02:29
01:41
23.5KB/s 00:00
Steps on destination server
6. Create directory structure same as target (source) database.
-p /data2/prod
-p /backup/archive/
7. Start the instance in nomount stage.
ORACLE_SID=prod
Production on Fri Apr 10 15:58:10 2015
Oracle. All rights reserved.
sysdba
instance.
1152450560 bytes
Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
Data Mining and Real Application Testing options
8. Connect to auxiliary instance via RMAN
auxiliary sys/oracle
11.2.0.1.0 – Production on Fri Apr 10 15:59:22 2015
Oracle and/or its affiliates. All rights
reserved.
database: PROD (not mounted)
9. Issue the following command to duplicate database with same name and same directory structure.
duplicate database to prod backup location ‘/backup/rman_backup’ nofilenamecheck;
10-APR-15
memory”;
from memory
database (not started)
Area 1152450560 bytes
scope=spfile”;
scope=spfile”;
‘/backup/rman_backup/controlfile_c-284539893-20150410-00’;
set db_name = ”PROD” comment= ”Modified by RMAN
duplicate” scope=spfile
set db_unique_name = ”PROD” comment= ”Modified by RMAN
duplicate” scope=spfile
Area 1152450560 bytes
10-APR-15
ORA_AUX_DISK_1
SID=63 device type=DISK
restoring control file
restore complete, elapsed time: 00:00:03
name=/data2/prod/control01.ctl
name=/data2/prod/control02.ctl
10-APR-15
ORA_AUX_DISK_1
ORA_AUX_DISK_1
device type=DISK
clause
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
10-APR-15
starting datafile backup set restore
specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data2/prod/system01.dbf
restoring datafile 00002 to /data2/prod/sysaux01.dbf
restoring datafile 00003 to /data2/prod/undotbs01.dbf
restoring datafile 00004 to /data2/prod/users01.dbf
restoring datafile 00005 to /data2/prod/example01.dbf
restoring datafile 00006 to /data2/prod/data01.dbf
restoring datafile 00007 to /data2/prod/test01.dbf
restoring datafile 00008 to /data2/prod/tools01.dbf
reading from backup piece /backup/rman_backup/db_arch_2rq41rqd_1_1.bkp
piece handle=/backup/rman_backup/db_arch_2rq41rqd_1_1.bkp
tag=TAG20150410T153956
restored backup piece 1
restore complete, elapsed time: 00:00:35
10-APR-15
datafile copy
STAMP=876672089 file name=/data2/prod/system01.dbf
datafile copy
STAMP=876672089 file name=/data2/prod/sysaux01.dbf
datafile copy
STAMP=876672090 file name=/data2/prod/undotbs01.dbf
datafile copy
STAMP=876672090 file name=/data2/prod/users01.dbf
datafile copy
STAMP=876672090 file name=/data2/prod/example01.dbf
datafile copy
STAMP=876672091 file name=/data2/prod/data01.dbf
datafile copy
STAMP=876672091 file name=/data2/prod/test01.dbf
datafile copy
STAMP=876672091 file name=/data2/prod/tools01.dbf
clause
10-APR-15
starting archived log restore to default destination
restoring archived log
sequence=146
reading from backup piece /backup/rman_backup/db_arch_2sq41rsf_1_1.bkp
piece handle=/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp
tag=TAG20150410T154103
restored backup piece 1
restore complete, elapsed time: 00:00:01
name=/backup/archive/1_146_872701561.dbf thread=1 sequence=146
deleting archived log(s)
name=/backup/archive/1_146_872701561.dbf RECID=1 STAMP=876672098
elapsed time: 00:00:04
10-APR-15
scope=spfile”;
database (not started)
Area 1152450560 bytes
set db_name = ”PROD” comment= ”Reset to original value
by RMAN” scope=spfile
reset db_unique_name scope=spfile
database (not started)
Area 1152450560 bytes
CONTROLFILE REUSE SET DATABASE “PROD” RESETLOGS ARCHIVELOG
1 ( ‘/data2/prod/redo01.log’ ) SIZE 50 M
REUSE,
2 ( ‘/data2/prod/redo02.log’ ) SIZE 50 M
REUSE,
3 ( ‘/data2/prod/redo03.log’ ) SIZE 50 M
REUSE
NEWNAME
/data2/prod/temp01.dbf in control file
name=/data2/prod/sysaux01.dbf RECID=1 STAMP=876672123
RECID=2 STAMP=876672123
name=/data2/prod/users01.dbf RECID=3 STAMP=876672124
name=/data2/prod/example01.dbf RECID=4 STAMP=876672124
name=/data2/prod/data01.dbf RECID=5 STAMP=876672125
name=/data2/prod/test01.dbf RECID=6 STAMP=876672125
name=/data2/prod/tools01.dbf RECID=7 STAMP=876672125
datafile copy
STAMP=876672123 file name=/data2/prod/sysaux01.dbf
datafile copy
STAMP=876672123 file name=/data2/prod/undotbs01.dbf
datafile copy
STAMP=876672124 file name=/data2/prod/users01.dbf
datafile copy
STAMP=876672124 file name=/data2/prod/example01.dbf
datafile copy
STAMP=876672125 file name=/data2/prod/data01.dbf
datafile copy
STAMP=876672125 file name=/data2/prod/test01.dbf
datafile copy
STAMP=876672125 file name=/data2/prod/tools01.dbf
10-APR-15
Production on Fri Apr 10 16:04:05 2015
Oracle. All rights reserved.
sysdba
Enterprise Edition Release 11.2.0.1.0 – 64bit Production
Data Mining and Real Application Testing options
name,open_mode from v$database;
——————–
v$instance;
tablespace_name,status from dba_tablespaces;
———
Conclusion
In the above article, we have learned that backup based duplication using Rman utility with same database name and same directory structure, we can refer this as targetless duplication, where no connectivity between target and auxiliary instance is required.
BY
Name: Omer
Designation: Senior Database Engineer
Organization: Netsoftmate IT Solutions.
Contact us: info@netsoftmate.com