Monday, December 9, 2013

Hot backup and cloning

1.       For Hot backup we have to put the Database in Archive Log mode.
$startup mount
SQL>alter database archivelog;
    2.       Next we need to take the backup of control file.
SQL>alter database backup controlfile to trace as ‘/opt/backup/control_file_backup.sql’
    3.       Then, we need to put the Database in backup mode,
SQL>alter database begin backup;
(If the database in backup mode, all the transactions will go to the archive log. But in my case, all the transactions saved in redo logs, since its empty, so I did,)
 SQL>alter system archive log current;
    4.       We need to create the directory structure for TARGET like as same as SOURCE.
(In my case SOURCE db name is orcl, TARGET name is test)
    5.       Copy the SOURCE pfile (/opt/oracle/admin/orcl/pfile) to TARGET (/opt/oracle/admin/test/pfile).
    6.       Edit the pfile according to TARGET
(escape:%s/orcl/test/g)
    7.       Copy only .dbf from SOURCE (/opt/oracle/oradata/orcl) to TARGET (/opt/oracle/oradata/test ).
    8.       Once the datafile copying is finished, we have to end the database backup mode,
SQL>alter database end backup;
    9.       Find the oracle SID,
$echo $ORACLE_SID
   10.   Export the current sid to TARGET sid,
$export ORACLE_SID=test
   11.   Next with the help of control file backup, we need to create the control files for TARGET, for that we need to edit the control file backup according to test.
$vi /opt/backup/control_file_backup.sql
(escape:%s/orcl/test/g)
(escape:%s/ORCL/TEST/g)
   12.   Connect the sqlplus & startup with TARGET database pfile & with nomount state.
$startup pfile=’/opt/oracle/admin/test/pfile/initTEST.ora’ nomount;
   13.   Execute the control file,
SQL>@/opt/backup/ control_file_backup.sql
   14.   Then we need to recover the Database with the help of the control file.
SQL>recover database using backup controlfile;
   15.   Apply the archive log files.
   16.   After reached the current archive log file, it will show Media Recovery Completed.
   17.   After applying all Archive files, still it didn’t show Media Recovery Completed, then apply the redo log files.
   18.   Then open the db with resetlogs,
alter database open resetlogs;

No comments :

Post a Comment