Oracle Database Blog‎ > ‎Backup & Recovery‎ > ‎RMAN‎ > ‎

Duplicate DB

-- Set user and ORACLE_SID
su - oracle
set ORACLE_SID=TARGETDB

sqlplus / as sysdba
SQL> shutdown abort

-- open host terminal
host
-- remove all database fiels (include redo and controlfiles)
rm -rf /ORACLE_DATA/*
-- exit to sql
exit

SQL> startup nomount

rman target sys/password@SOURCEDB catalog rman/rman@rman_catalog AUXILIARY sys/password log /tmp/dupl_src_trg_date.log

RUN
{
  ALLOCATE AUXILIARY CHANNEL newdb1 DEVICE TYPE sbt;
  DUPLICATE TARGET DATABASE TO TARGETDB UNTIL TIME "TO_DATE('20.12.2012 15:00:00','DD.MM.YYYY HH24:MI:SS')"
  DB_FILE_NAME_CONVERT=('/ORACLE_DATA/SOURCEDB/','/ORACLE_DATA/TARGETDB/')
  LOGFILE
    GROUP 1 ('/ORACLE_DATA/TARGETDB/log1a.rdo', 
        '/ORACLE_DATA/TARGETDB/log1b.rdo') SIZE 100M,
    GROUP 2 ('/ORACLE_DATA/TARGETDB/log2a.rdo', 
        '/ORACLE_DATA/TARGETDB/log2b.rdo') SIZE 100M,
    GROUP 3 ('/ORACLE_DATA/TARGETDB/log3a.rdo', 
        '/ORACLE_DATA/TARGETDB/log3b.rdo') SIZE 100M,
    GROUP 4 ('/ORACLE_DATA/TARGETDB/log4a.rdo', 
        '/ORACLE_DATA/TARGETDB/log4b.rdo') SIZE 100M;
}

ALTER TABLESPACE TEMP ADD TEMPFILE ''/ORACLE_DATA/TARGETDB/temp.dbf' SIZE 1000M REUSE AUTOEXTEND OFF;