Oracle – Cloning Database – Cold Cloning, Hot Cloning

PC & Tech Category

Clone an Oracle Database using Cold Physical Backup

Database Name: troy

Source Database side: (Troy database)

Cold Backup Steps

1. Get the file path information using below query

Select name from v$datafile;

Select member from v$logfile;

Select name from v$controlfile;

2. Parameter file backup

If troy database running on spfile

Create pfile=/u01/backup/inittroy.ora from spfile;

If database running in pfile using os command to copy the pfile and placed in backup path.

3.Taken the control file backup

Alter database backup controlfile to trace as /u01/backup/control01.ora;

4.Shutdown immediate

5.Copy all the data files/log files using os command & placed in backup path.

6.Startup the database.

Clone Database side: (Clone database)

Database Name: Clone

Clone Database Steps:

1.Create the appropriate folder in corresponding path & placed the backup files in corresponding folder.(bdump,udump,create,pfile,cdump,oradata)

2.Change the init.ora parameter like control file path, dbname, instance name etc…

3.Create the password file using orapwd utility.

(Database in windows we need to create the service id using oradim utility)

4.Startup the Database in NOMOUNT stage.

5.Create the control file for cloning database.

Using backup controlfile trace to generate the create controlfile scripts.

Change the Database name & files path, also change ‘REUSE’ needs to be changed to ‘SET’.

CREATE CONTROLFILE SET DATABASE “clone” RESETLOGS FORCE LOGGING NOARCHIVELOG
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 453
LOGFILE
GROUP 1 ‘/U01/oradata/clone/redo01.log’ SIZE 200M,
GROUP 2 ‘/U01/oradata/clone/redo02.log’ SIZE 200M,
GROUP 3 ‘/U01/oradata/clone/redo03.log’ SIZE 200M
DATAFILE
‘/U01/oradata/clone/system01.dbf’,
‘/U01/oradata/clone/undotbs01.dbf’,
‘/U01/oradata/clone/users01.dbf’,
CHARACTER SET WE8ISO8859P1;

Note: placed the script in sql prompt. Now controlfile created.

6.Now open the database.

Alter database open resetlogs;

Note: Check the logfile, datafiles & instance status

**********************************************************************************

Clone an Oracle Database using Hot Physical Backup

Database Name: troy

Database must be in Archive log mode.

Source Database side: (Troy database)

Hot Backup Steps:

1.Get the file path information using below query.

Select tablespace_name, file_name from dba_data_files order by 1;

2. Parameter file backup

If troy database running on spfile

Create pfile=/u01/backup/inittroy.ora from spfile;

If database running in pfile using os command to copy the pfile and placed in backup path.

3.Put the tablespace in begin backup mode Using os command to copy the datafiles belongs to begin backup mode tablespace & placed in backup path. (Refer below example)

4.Once copied the datafile, release the tablespace from begin backup mode to end backup

5.Repeat the steps 1-3 for all your tablespaces.

6.Taken the controlfile backup

Alter database backup controlfile to trace as /u01/backup/control01.ora;

7.Backup all your archive log files between the previous backup and the new backup as well.

Example:

Steps:

1.Alter tablespace system begin backup;

To ensure the begin backup mode tablespace using below query

Select * from v$backup; (refer the Change#, Time column)

2. Host cp /u01/oracle/raja/system1.DBF /u01/backup/system01.dbf using os command to copy the datafile.

3. Alter tablespace system end backup;

To ensure the begin backup mode tablespace using below query

Select * from v$backup;

Clone Database side: (Clone database)

Database Name: Clone

Clone Database Steps:

1. Create the appropriate folder in corresponding path & placed the backup files in corresponding folder.(bdump,udump,create,pfile,cdump,oradata)

2. Change the init.ora parameter like control file path, dbname, instance name etc…

3. Create the password file using orapwd utility.

(Database in windows we need to create the service id using oradim utility)

4.Startup the Database in NOMOUNT stage.

5.Create the control file for cloning database.

Using backup controlfile trace to generate the create controlfile scripts.

Change the Database name & files path, also change ‘REUSE’ needs to be changed to ‘SET’.

CREATE CONTROLFILE SET DATABASE “clone” RESETLOGS FORCE LOGGING NOARCHIVELOG
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 453
LOGFILE
GROUP 1 ‘/U01/oradata/clone/redo01.log’ SIZE 200M,
GROUP 2 ‘/U01/oradata/clone/redo02.log’ SIZE 200M,
GROUP 3 ‘/U01/oradata/clone/redo03.log’ SIZE 200M
DATAFILE
‘/U01/oradata/clone/system01.dbf’,
‘/U01/oradata/clone/undotbs01.dbf’,
‘/U01/oradata/clone/users01.dbf’,
CHARACTER SET WE8ISO8859P1;

Note: placed the script in sql prompt. Now controlfile created.

6.Recover the database using controlfile.

Recover database using backup controlfile until cancel;

7.Now open the database.

Alter database open resetlogs;

Note: Check the logfile, datafiles status.

I Hope this article helped you to understand the cloning oracle database.Suggestions are welcome.

Tags:

Edward Ramamoorthy Avatar

Help Us Grow

If you like this post, please share it with your friends.

You are free to copy and redistribute this article in any medium or format, as long as you keep the links in the article or provide a link back to this page.

Subscribe to Newsletter




Privacy Settings

Privacy & Cookie Overview

Our website uses cookies to provide you with the best user experience possible. These cookies are stored in your browser and perform essential functions such as recognizing you when you return to our website, as well as helping us to understand which sections of the website you find most useful and engaging.

To learn more, you can read our Privacy & Cookie Policy or reach out through our Contact form.

Strictly Necessary Cookies

Strictly Necessary Cookies must always be enabled to ensure the proper functioning of this website and to allow us to provide you with excellent service. These cookies are also essential for saving your cookie preferences.

Google Adsense

We use Google AdSense to keep this site free by displaying relevant ads. AdSense requires essential cookies that cannot be disabled, but you can manage other cookies. We respect your privacy and provide options to control non-essential cookies.

For more details on how Google handles your data, visit Google's Data Usage Policy. Please review our Privacy Policy for more information on how we protect your data.

AddToAny

We use AddToAny for social sharing. It doesn’t store cookies, ensuring a privacy-friendly experience. AddToAny complies with GDPR and CCPA by default.

For more, see their Privacy Policy.

OneSignal

We use OneSignal to send notifications to users who opt in. OneSignal complies with GDPR and is certified under the EU-US and Swiss-US Privacy Shield frameworks.

For more, see their Privacy Policy.

3rd Party Cookies

This website utilizes third-party cookies, which can enhance your experience and support our ongoing efforts to improve our services.

Google Analytics

We use Google Analytics to collect anonymous data, such as visitor numbers and popular pages, to improve user experience and site performance. Keeping this cookie enabled helps us refine the site based on visitor activity.

For more information, see Google’s Privacy Policy.

Discover more from Prime Inspiration

Subscribe now to keep reading and get access to the full archive.

Continue reading