Tuesday, October 13, 2009

Cloning Database From Hot Backup

Cloning Database From Hot Backup
To clone a db on another machine from hot backup, follow these steps:
1. Install Oracle server on new machine
2. Create directories, init p-file, data files, redo log files, trace of control file, archive from the original database on to second server where you need to clone
3. Add database name to tnsnames.ora, listener.ora on second server
4. Create database service with ORADIM (if OS is Windows)
Eg: oradim -new -sid -intpwd -pfile -startmode auto
5. On original db:
ALTER DATABASE BACKUP CONTROL FILE TO TRACE RESETLOGS;
6. Rename trace file to create_control.sql, edit the contents as follows:
STARTUP NOMOUNT CREATE CONTROLFILE SET DATABASE "" RESETLOGS ARCHIVELOG ... ;
7. On original db Then do:
ALTER SYSTEM ARCHIVE LOG CURRENT;
8. Copy the ORADATA directory including archived logs to second server
9. Go to second server, set SID, and use sqlplus to connect as SYSDBA
10. Delete the control files already copied over using OS commands
11.set the SID
If oracle: set $ORACLE_SID=
If windows: set ORACLE_SID=
12. Run the CREATE CONTROL file script shown above
create_control.sql
13. Issue: RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
---------------------------------------------------------------------
select ' alter tablespace ' tablespace_name ' begin backup ;' from dba_tablespaces;
select ' alter tablespace ' tablespace_name ' end backup ;' from dba_tablespaces;

No comments: