Clone Database Using Hotbackup


Clone database using “Hot-backup”

Step 1 : Take database hot backup as follows

We must make sure that the present online logs are all switched and archived which helps us in reducing time consumed in the media recovery of the target database.
Query to find out the number of log groups that are present in the database and perform log switch as many number of times as the log groups

Step2 : 
Select group#,archived,status from v$log;

GROUP#     ARCHIVED    STATUS
1               YES              INACTIVE
2               NO               CURRENT

SQL> alter system switch logfile;
SQL> alter system switch logfile;

Make sure no log group shows STALE status.

SQL> alter database begin backup;
Go to the OS level and perform the copy of the datafiles
$ cp *.dbf to backup location 
note * (for hot backup, we will need not take backup of redolog files)
sql> alter database end backup;
sql> alter system switch logfile;
$ cp *.ctl to backup location
Note: If you are using 9i database, use “tablespace begin backup/end backup” clauses

step 2 : Take backup of spfile or pfile from the source database along with archives
step 3 : Do a fresh Installation of oracle software in target server 
note* (select the 'software only' option in OUI)

Copy source database files to the target database

step 4 : transfer or copy the files to target database server either using FTP or any methods
step 5 : place pfile or spfile in dbs directory of the target database.
step 6 : copy all files such as (datafiles, controlfiles and archives) to their respective locations
step 7 : Perform the following :-
SQL> startup nomount
SQL> alter database mount;
SQL> recover database using backup controlfile until cancel;
At this point it may ask you to apply archives and will give suggestion as file name and path. apply required archives
step 8 : finally, open your database with resetlogs option
sql> alter database open resetlogs;
At times you may get following error while performing a hot backup cloning
ORA-01194 file 1 needs more recovery to be consistent error
in such cases, do a switch logfile in source database server and copy & apply that archive logfile in target server