Making a Copy of Your Database on UNIX

This module describes how you can make a copy of your database on the UNIX operating system.

This module discusses the following:

Overview
Making a Copy of Your Database On UNIX

Move your mouse over this icon to show all screenshots. You can also move your mouse over each individual icon to see only the screenshot associated with it.

Back to List of Topics

You can create a copy of your database on the same UNIX machine by following the steps outlined below.

Note: If you are using a release of Oracle prior to Oracle9i Release 2, you should not use this procedure if you are using Recovery Manager (RMAN) to back up your database.

As an alternative to these procedures, you can use the RMAN DUPLICATE command to create a duplicate database from target database backups.

Back to List of Topics

You will make a copy of the files that comprise your database. You will then create a new control file by executing a script you generate from your existing control file.

Note: Creating a copy of a database involves usage of the CREATE CONTROLFILE command. If this command is not executed correctly, your database could be corrupted. If this happens and the files in question are important, you will need to restore the original database from a backup.

You can make a copy of your database by performing the following steps:

1.

Invoke SQL*Plus and connect as a user with SYSDBA privileges.

 

2.

Issue the following command to create a script that will be used to generate your new control file.

ALTER DATABASE BACKUP CONTROLFILE TO TRACE RESETLOGS;

Move your mouse over this icon to see the image

 

3.

This command generates a trace file that will be stored in the location specified by the USER_DUMP_DEST initialization parameter. The file will be named ORA_nnnn.trc. You can find the value of USER_DUMP_DEST by issuing the following command:

SHOW PARAMETER USER_DUMP_DEST


Move your mouse over this icon to see the image


4.

Copy this file to a file named ccf<NEW_SID>.sql (or other name of your choice) where NEW_SID is the system identifier (ORACLE_SID) of your copied database.

 

5.

You must identify the data files and redo log files that you need to copy for your new database. You can view the file names in the trace file you created in step 2. Alternatively, you can perform the following queries to obtain the file names:

SELECT name FROM v$datafile;

Move your mouse over this icon to see the image

SELECT member FROM v$logfile;


Move your mouse over this icon to see the image

 

6.

Shut down your instance using the NORMAL, IMMEDIATE, or TRANSACTIONAL options:

SHUTDOWN IMMEDIATE

Move your mouse over this icon to see the image

 

7.

Make a whole (full or complete) backup of your database files. You should include the data files and redo log files you identified in step 3. In addition you should back up the server parameter file, initialization parameter file and any additional parameter files indicated by the IFILE initialization parameter.

 

8.

Copy your data files, redo log files, control files, and initialization parameter files to the new location. Be sure to preserve the file ownership and privileges.

 

9.

Change the name of the initialization parameter file to use your new system identifier (ORACLE_SID).

 

10.

Edit the initialization parameter file for your copied database. Change the value of the CONTROL_FILES parameter to your new control file names. Change the value of the DB_NAME parameter to the database name of your copied database.

 

11.

Edit the trace file you created in step 2 to make the following changes:

Remove the comment lines and the STARTUP NOMOUNT statement that precede the CREATE CONTROLFILE statement.

Remove the comment lines and the RECOVER DATABASE and ALTER DATABASE OPEN commands that follow the CREATE CONTROLFILE statement.

Add the SET DATABASE clause and change the database name to your new database name as in the following example.
Change:
CREATE CONTROLFILE REUSE DATABASE "DB1" RESETLOGS
To:
CREATE CONTROLFILE REUSE SET DATABASE "DB2" RESETLOGS

Change the data file and redo log file names to the names for your copied database

Note: If you omit any files from the CREATE CONTROLFILE command, these files cannot be added to the new database at a later date. If any of the file names are not changed from their original names in the CREATE CONTROLFILE command, the files of the original database will become part of the copied database and it will not be possible to restore them to the original database. If this happens, the original database will need to be restored from a backup.


Move your mouse over this icon to see the image

 

12.

If you are using a password file for authentication, you should create a new password file for your copied database using the ORAPWD utility.

orapwd file=orapw<SID> password=<your password> entries=

Move your mouse over this icon to see the image

 

13.

At the operating system prompt, change the value of the ORACLE_SID environment variable to your new ORACLE_SID. You can use the following command in the C shell:

%setenv ORACLE_SID <NEW_SID>

Move your mouse over this icon to see the image

 

14.

Invoke SQL*Plus and connect as a user with SYSDBA privileges.

 

15.

Start your instance in NOMOUNT mode:

STARTUP NOMOUNT PFILE=<pfile name>

Move your mouse over this icon to see the image

 

16.

Execute your SQL script to create a new control file:

@ccf<new sid>

Move your mouse over this icon to see the image

 

17.

Open your database with the RESETLOGS option:

ALTER DATABASE OPEN RESETLOGS;

Move your mouse over this icon to see the image

 

18.

Make a whole (full or complete) backup of your database using operating system commands or RMAN.

 

Move your mouse over this icon to hide all screenshots