Overview This article provides a quick introduction on how to duplicate a database using the RMAN DUPLICATE DATABASE command

on the UNIX / Linux operating environment. For this demonstration, we will create a duplicate target database using RMAN's DUPLICATE DATABASE command to the same host (localhost) of the target database. Please keep in mind that this article should not be considered a substitution for completing reading and understanding the official documentation and release notes from Oracle. The following links can be used to download the Recovery Manager User's Guide for Oracle9i (9.2.0): Oracle9i Database Release 2 Documentation Oracle9i Recovery Manager User's Guide - (A96566-01) Here is a short introduction to some of the configuration parameters that will be used for installing the Oracle RDBMS Software:
Operating Environment Oracle Release / Version ORACLE_BASE ORACLE_HOME Target Database SID Duplicate Database SID RMAN Catalog Database Archive Log Mode log_archive_dest_1 log_archive_dest_state_1 log_archive_format log_archive_start RMAN Default Configuration Settings Red Hat Linux - Fedora Core 2 9.2.0.5.0 Enterprise Edition /u01/app/oracle /u01/app/oracle/product/9.2.0 ORA920 TESTDB No recovery catalog. Using control file. Enabled location=/u06/app/oradata/ORA920/archive mandatory enable arch_t%t_s%s.dbf true RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/orabackup/ORA920/%F'; CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT

. Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers Database mounted. # default It is a common request to create a duplicated database from a production database.5.2. RMAN configuration has no stored or default parameters CONFIGURE MAXSETSIZE TO UNLIMITED. # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.Production on Wed Nov 3 16:42:34 2004 Copyright (c) 1982. SQL> startup open ORACLE instance started.0 . This can be easily achieved using the RMAN DUPLICATE command. and then importing it back into the production database. this article will demonstrate how to create a completely identical database. the DBA can create a duplicate database from a target database's backup while still retaining the original target database.14 B A A 15 B F A 16 B A A 17 B F A Device Type ----------DISK DISK DISK DISK Completion Time --------------03-NOV-04 03-NOV-04 03-NOV-04 03-NOV-04 #Pieces ------1 1 1 1 #Copies ------1 1 1 1 Tag --TAG20041103T163334 TAG20041103T163336 TAG20041103T163651 Target database must be mounted or open $ sqlplus "/ as sysdba" SQL*Plus: Release 9. Using this method allows you to test backup and recovery procedures as well as exporting data such as a table that was inadvertently dropped from the production database. 252777660 451772 218103808 33554432 667648 bytes bytes bytes bytes bytes All rights reserved.0.0/dbs/snapcf_ORA920.-.-.f'. List of Backups =============== Key TY LV S ------. Oracle Corporation. Pre-requisites A valid full database backup of the target database RMAN> list backup summary.'/orabackup/ORA920/backup_DB_%d_S_%s_P_%s_T_%t'. Connected to an idle instance.2. While it is possible to create a duplicate database that contains only a subset of the original database (by tablespace). 2002. Using the RMAN DUPLICATED command.

IDEVELOPMENT. '/u06/app/oradata/TESTDB') log_file_name_convert = ('/u03/app/oradata/ORA920'.0/dbs/initTESTDB. $ export ORACLE_SID=ORA920 $ sqlplus "/ as sysdba" SQL> create pfile='/u01/app/oracle/product/9. File created. '/u04/app/oradata/ORA920'. Create / Start the Auxiliary Instance .ctl' . change at least the following parameters: db_file_name_convert = ('/u06/app/oradata/ORA920'. SQL> exit Steps Required 1.2. '/u03/app/oradata/TESTDB'. After creating the initialization parameter for the duplicate database. Create an Initialization Parameter for the Auxiliary Database Copy the initialization parameter from the target database and make the necessary changes for the duplicated database.INFO' dispatchers = '(PROTOCOL=TCP) (SERVICE=TESTDBXDB)' log_archive_dest_1 = 'location=/u06/app/oradata/TESTDB/archive mandatory' 3.Database opened. '/u04/app/oradata/TESTDB'.ora' from spfile.2.ctl' .0/dbs/orapwTESTDB password=change_on_install 2.ctl' db_name = 'TESTDB' instance_name = 'TESTDB' audit_file_dest = '/u01/app/oracle/admin/TESTDB/adump' background_dump_dest = '/u01/app/oracle/admin/TESTDB/bdump' core_dump_dest = '/u01/app/oracle/admin/TESTDB/cdump' user_dump_dest = '/u01/app/oracle/admin/TESTDB/udump' service_names = 'TESTDB. '/u05/app/oradata/TESTDB') control_files = '/u03/app/oradata/TESTDB/control01. Create Password File for Auxiliary Database $ orapwd file=/u01/app/oracle/product/9. '/u05/app/oradata/TESTDB/control03. '/u04/app/oradata/TESTDB/control02. '/u05/app/oradata/ORA920'.

Production on Wed Nov 3 17:43:22 2004 Copyright (c) 1982.5. $ export ORACLE_SID=ORA920 $ sqlplus "/ as sysdba" . so a valid password file must exist.0 . After making changes to the networking files.0.0. the target database should be either opened or mounted. reserved. OLAP and Oracle Data Mining options JServer Release 9.5.0 .5. All rights Connected to: Oracle9i Enterprise Edition Release 9. Mount or Open the Target Database As mentioned in the pre-requisites section of this article.Production With the Partitioning.2. $ sqlplus "sys/change_on_install@TESTDB as sysdba" SQL*Plus: Release 9. test the connection keeping in mind that you must be able to connect to the auxiliary instance with SYSDBA privileges. Ensure Oracle Net Connectivity to Auxiliary Database Modify both the listener.2.0 .2.Production SQL> 5.Create all needed directories for the duplicate database: $ $ $ $ $ $ $ $ $ $ $ $ $ mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir mkdir /u01/app/oracle/admin/TESTDB /u01/app/oracle/admin/TESTDB/adump /u01/app/oracle/admin/TESTDB/bdump /u01/app/oracle/admin/TESTDB/cdump /u01/app/oracle/admin/TESTDB/create /u01/app/oracle/admin/TESTDB/pfile /u01/app/oracle/admin/TESTDB/scripts /u01/app/oracle/admin/TESTDB/udump /u03/app/oradata/TESTDB /u04/app/oradata/TESTDB /u05/app/oradata/TESTDB /u06/app/oradata/TESTDB /u06/app/oradata/TESTDB/archive $ export ORACLE_SID=TESTDB $ sqlplus "/ as sysdba" SQL> startup nomount 4.ora file to be able to connect to the auxiliary database.0. 2002. Oracle Corporation.ora and tnsnames.

to duplicate the new database to yesterdays date/time. run { # Allocate the channel for the duplicate work allocate auxiliary channel ch1 type disk. List of Backups =============== Key TY LV S Device Type ------.------.SQL> startup open 6. 13.-.. Oracle Corporation. Recovery Manager: Release 9. 10.Run the RMAN DUPLICATE DATABASE Command The following RUN block can be used to fully duplicate the target database from the latest full backup. All rights reserved. 14.-. Ensure You Have the Necessary Backups and Archived Redo Log Files As mentioned in the pre-requisites section of this article. ensure that you have a current backup that you wish to use to create the duplicate database. . 12. connected to target database: ORA920 (DBID=2542332757) 15.2.5.----------14 B A A DISK TAG20041103T163334 15 B F A DISK TAG20041103T163336 16 B A A DISK TAG20041103T163651 17 B F A DISK Completion Time #Pieces #Copies Tag --------------. connected to auxiliary database: TESTDB (not mounted) 16.------..0.0 . $ rman target sys/change_on_install@ORA920 auxiliary sys/change_on_install@TESTDB 9. use the following: duplicate target database to TESTDB until time 'SYSDATE-1'.--03-NOV-04 1 1 03-NOV-04 03-NOV-04 03-NOV-04 1 1 1 1 1 1 7.Production 11. 2002. RMAN> 17. Copyright (c) 1995. For example. # Duplicate the database to TESTDB duplicate target database to TESTDB. Note that you can duplicate the database to a specific date/time using the UNTIL TIME '<DATE>' clause. Login to Target and Auxiliary Database using RMAN 8. Login to query the RMAN catalog: $ rman target sys/change_on_install@ORA920 RMAN> list backup summary.

dbf".dbf". set newname for datafile 6 to "/u06/app/oradata/TESTDB/odm01.dbf".dbf".} using target database controlfile instead of recovery catalog allocated channel: ch1 channel ch1: sid=13 devtype=DISK Starting Duplicate Db at 03-NOV-04 printing stored script: Memory Script { set until scn 14757706. set newname for datafile 7 to "/u06/app/oradata/TESTDB/tools01. set newname for datafile 11 to "/u06/app/oradata/TESTDB/perfstat01. set newname for datafile 3 to "/u06/app/oradata/TESTDB/cwmlite01.dbf". set newname for datafile 1 to "/u06/app/oradata/TESTDB/system01. set newname for datafile 5 to "/u06/app/oradata/TESTDB/indx01. set newname for datafile 8 to "/u06/app/oradata/TESTDB/users01. restore check readonly clone database .dbf". set newname for datafile 4 to "/u06/app/oradata/TESTDB/drsys01.dbf".dbf".dbf". set newname for datafile 9 to "/u06/app/oradata/TESTDB/xdb01. set newname for datafile 10 to "/u06/app/oradata/TESTDB/example01.dbf". set newname for datafile 2 to "/u06/app/oradata/TESTDB/undotbs1_01. set newname for datafile 12 to "/u06/app/oradata/TESTDB/users02.dbf".dbf". } executing script: Memory Script executing command: SET until clause executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME .

log' ) SIZE 104857600 REUSE. '/u05/app/oradata/TESTDB/redo_g03c.dbf restoring datafile 00011 to /u06/app/oradata/TESTDB/perfstat01. '/u05/app/oradata/TESTDB/redo_g01c.log' ) SIZE 104857600 REUSE.log'.executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at 03-NOV-04 channel ch1: starting datafile backupset restore channel ch1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u06/app/oradata/TESTDB/system01.dbf restoring datafile 00005 to /u06/app/oradata/TESTDB/indx01.log'. GROUP 3 ( '/u03/app/oradata/TESTDB/redo_g03a.dbf restoring datafile 00002 to /u06/app/oradata/TESTDB/undotbs1_01. '/u05/app/oradata/TESTDB/redo_g02c.dbf restoring datafile 00010 to /u06/app/oradata/TESTDB/example01.dbf restoring datafile 00006 to /u06/app/oradata/TESTDB/odm01. GROUP 2 ( '/u03/app/oradata/TESTDB/redo_g02a.log'.dbf' CHARACTER SET WE8ISO8859P1 . '/u04/app/oradata/TESTDB/redo_g02b.log' ) SIZE 104857600 REUSE DATAFILE '/u06/app/oradata/TESTDB/system01.log'.log'.log'.dbf restoring datafile 00003 to /u06/app/oradata/TESTDB/cwmlite01.dbf restoring datafile 00007 to /u06/app/oradata/TESTDB/tools01. '/u04/app/oradata/TESTDB/redo_g01b.dbf channel ch1: restored backup piece 1 piece handle=/orabackup/ORA920/backup_DB_ORA920_S_16_P_16_T_541269216 tag=TAG20041103T163336 params=NULL channel ch1: restore complete Finished restore at 03-NOV-04 sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 5 MAXDATAFILES 600 MAXINSTANCES 10 MAXLOGHISTORY 1134 LOGFILE GROUP 1 ( '/u03/app/oradata/TESTDB/redo_g01a.dbf restoring datafile 00008 to /u06/app/oradata/TESTDB/users01.dbf restoring datafile 00004 to /u06/app/oradata/TESTDB/drsys01. '/u04/app/oradata/TESTDB/redo_g03b.dbf restoring datafile 00012 to /u06/app/oradata/TESTDB/users02.dbf restoring datafile 00009 to /u06/app/oradata/TESTDB/xdb01.

dbf datafile 4 switched to datafile copy input datafilecopy recid=3 stamp=541274660 filename=/u06/app/oradata/TESTDB/drsys01.dbf datafile 8 switched to datafile copy input datafilecopy recid=7 stamp=541274660 filename=/u06/app/oradata/TESTDB/users01.dbf datafile 10 switched to datafile copy input datafilecopy recid=9 stamp=541274660 filename=/u06/app/oradata/TESTDB/example01. recover clone database delete archivelog .dbf datafile 5 switched to datafile copy input datafilecopy recid=4 stamp=541274660 filename=/u06/app/oradata/TESTDB/indx01.dbf datafile 6 switched to datafile copy input datafilecopy recid=5 stamp=541274660 filename=/u06/app/oradata/TESTDB/odm01.dbf datafile 9 switched to datafile copy input datafilecopy recid=8 stamp=541274660 filename=/u06/app/oradata/TESTDB/xdb01.dbf datafile 11 switched to datafile copy input datafilecopy recid=10 stamp=541274660 filename=/u06/app/oradata/TESTDB/perfstat01. } executing script: Memory Script datafile 2 switched to datafile copy input datafilecopy recid=1 stamp=541274660 filename=/u06/app/oradata/TESTDB/undotbs1_01.dbf datafile 12 switched to datafile copy input datafilecopy recid=11 stamp=541274660 filename=/u06/app/oradata/TESTDB/users02.printing stored script: Memory Script { switch clone datafile all.dbf printing stored script: Memory Script { set until scn 14757706. } executing script: Memory Script executing command: SET until clause Starting recover at 03-NOV-04 starting media recovery channel ch1: starting archive log restore to default destination .dbf datafile 7 switched to datafile copy input datafilecopy recid=6 stamp=541274660 filename=/u06/app/oradata/TESTDB/tools01.dbf datafile 3 switched to datafile copy input datafilecopy recid=2 stamp=541274660 filename=/u06/app/oradata/TESTDB/cwmlite01.

'/u05/app/oradata/TESTDB/redo_g01c.log' ) SIZE 104857600 REUSE.log'. '/u05/app/oradata/TESTDB/redo_g03c.log'.log' ) SIZE 104857600 REUSE.channel ch1: restoring archive log archive log thread=1 sequence=151 channel ch1: restored backup piece 1 piece handle=/orabackup/ORA920/backup_DB_ORA920_S_17_P_17_T_541269412 tag=TAG20041103T163651 params=NULL channel ch1: restore complete archive log filename=/u06/app/oradata/TESTDB/archive/arch_t1_s151. startup clone nomount . } executing script: Memory Script database dismounted Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 252777660 bytes Fixed Size 451772 bytes Variable Size 218103808 bytes Database Buffers 33554432 bytes Redo Buffers 667648 bytes sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 5 MAXDATAFILES 600 MAXINSTANCES 10 MAXLOGHISTORY 1134 LOGFILE GROUP 1 ( '/u03/app/oradata/TESTDB/redo_g01a. '/u04/app/oradata/TESTDB/redo_g01b.log'.log'.dbf thread=1 sequence=151 channel clone_default: deleting archive log(s) archive log filename=/u06/app/oradata/TESTDB/archive/arch_t1_s151. '/u04/app/oradata/TESTDB/redo_g02b.dbf recid=1 stamp=541274663 media recovery complete Finished recover at 03-NOV-04 printing stored script: Memory Script { shutdown clone. GROUP 3 ( '/u03/app/oradata/TESTDB/redo_g03a. '/u04/app/oradata/TESTDB/redo_g03b.log' ) SIZE 104857600 REUSE DATAFILE . '/u05/app/oradata/TESTDB/redo_g02c.log'.log'. GROUP 2 ( '/u03/app/oradata/TESTDB/redo_g02a.

dbf".dbf recid=3 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/indx01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/drsys01.dbf". } executing script: Memory Script cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/undotbs1_01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/users02.dbf".dbf".dbf' CHARACTER SET WE8ISO8859P1 printing stored script: Memory Script { catalog clone datafilecopy "/u06/app/oradata/TESTDB/undotbs1_01.dbf". switch clone datafile all. catalog clone datafilecopy "/u06/app/oradata/TESTDB/indx01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/tools01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/odm01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/perfstat01.dbf".dbf recid=6 stamp=541274721 cataloged datafile copy .dbf recid=4 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/odm01.dbf".dbf".dbf".dbf".dbf recid=2 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/drsys01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/xdb01.dbf". catalog clone datafilecopy "/u06/app/oradata/TESTDB/users01.dbf recid=5 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/tools01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/example01. catalog clone datafilecopy "/u06/app/oradata/TESTDB/cwmlite01.'/u06/app/oradata/TESTDB/system01.dbf recid=1 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/cwmlite01.

dbf datafile 5 switched to datafile copy input datafilecopy recid=4 stamp=541274721 filename=/u06/app/oradata/TESTDB/indx01.dbf datafile 6 switched to datafile copy input datafilecopy recid=5 stamp=541274721 filename=/u06/app/oradata/TESTDB/odm01.dbf datafile 4 switched to datafile copy input datafilecopy recid=3 stamp=541274721 filename=/u06/app/oradata/TESTDB/drsys01. } .dbf datafile 3 switched to datafile copy input datafilecopy recid=2 stamp=541274721 filename=/u06/app/oradata/TESTDB/cwmlite01.dbf recid=7 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/xdb01.dbf recid=10 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/users02.dbf printing stored script: Memory Script { Alter clone database open resetlogs.dbf datafile 11 switched to datafile copy input datafilecopy recid=10 stamp=541274721 filename=/u06/app/oradata/TESTDB/perfstat01.dbf datafile 8 switched to datafile copy input datafilecopy recid=7 stamp=541274721 filename=/u06/app/oradata/TESTDB/users01.dbf recid=11 stamp=541274721 datafile 2 switched to datafile copy input datafilecopy recid=1 stamp=541274721 filename=/u06/app/oradata/TESTDB/undotbs1_01.dbf recid=8 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/example01.dbf recid=9 stamp=541274721 cataloged datafile copy datafile copy filename=/u06/app/oradata/TESTDB/perfstat01.dbf datafile 9 switched to datafile copy input datafilecopy recid=8 stamp=541274721 filename=/u06/app/oradata/TESTDB/xdb01.datafile copy filename=/u06/app/oradata/TESTDB/users01.dbf datafile 12 switched to datafile copy input datafilecopy recid=11 stamp=541274721 filename=/u06/app/oradata/TESTDB/users02.dbf datafile 10 switched to datafile copy input datafilecopy recid=9 stamp=541274721 filename=/u06/app/oradata/TESTDB/example01.dbf datafile 7 switched to datafile copy input datafilecopy recid=6 stamp=541274721 filename=/u06/app/oradata/TESTDB/tools01.

. Tablespace altered. you will need to create the tempfiles for your temporary tablespace: $ export ORACLE_SID=TESTDB $ sqlplus "/ as sysdba" SQL> alter tablespace temp add tempfile '/u06/app/oradata/TESTDB/temp01.executing script: Memory Script database opened Finished Duplicate Db at 03-NOV-04 RMAN> exit 18.Create All tempfiles for Temporary Tablespace In almost all cases.dbf' 2 size 524288000 reuse autoextend on next 524288000 maxsize 1500M.