Thursday 20 August 2015

Rman duplicate database skip tablespace

RMAN - Duplicate database with skip tablespace.

This scenario when any table got dropped and user just need those table data. Duplicate database by skipping unrequited tablespace. Export required table from duplicate  database.

We can use point in time recovery too.

Source DB - orcl
Temp Db   - test2

SYS@clone> select name from v$tablespace;

NAME
------------------------------
SYSTEM
TEMP
SYSAUX
SYS_UNDOTS


6 rows selected.



C:\Windows\system32>rman auxiliary / target sys/orcl@clone

Recovery Manager: Release 11.1.0.6.0 - Production on Fri Aug 21 01:42:46 2015

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: CLONE (DBID=939948083)
connected to auxiliary database: TEST2 (not mounted)

RMAN> run
2> {
3> ##SET NEWNAME FOR DATABASE TO 'C:\APP\DILIP\ORADATA\backup_clone\test2\%b';  11.2.0 feature
4> ###set until time "to_date('13-apr-2014 00:37:26', 'dd-mon-yyyy hh24:mi:ss')";
5> set newname for tempfile 1 to 'C:\APP\DILIP\ORADATA\backup_clone\test2\TEMP01.DBF';
6> DUPLICATE TARGET DATABASE TO test2 SKIP TABLESPACE tt1,tt
7> LOGFILE
8>   GROUP 1 ('C:\APP\DILIP\ORADATA\backup_clone\test2\t_log1.f')  SIZE 10m,
9>   GROUP 2 ('C:\APP\DILIP\ORADATA\backup_clone\test2\t_log2.f') SIZE 10m;
10> }

executing command: SET NEWNAME
using target database control file instead of recovery catalog

Starting Duplicate Db at 21-AUG-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=98 device type=DISK
Datafile 4 skipped by request
Datafile 5 skipped by request

contents of Memory Script:
{
   set until scn  325074;
   set newname for datafile  1 to
 "C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSTEM01.DBF";
   set newname for datafile  2 to
 "C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF";
   set newname for datafile  3 to
 "C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF";
   restore
   clone database
   skip tablespace  "TT1",
 "TT"   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 21-AUG-15
using channel ORA_AUX_DISK_1

skipping datafile 3; already restored to file C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\DILIP\ORADATA\BACKUP_CLONE\BACKUP_CLONE\_21_20150821_2JQF46C1_1_1
channel ORA_AUX_DISK_1: piece handle=C:\APP\DILIP\ORADATA\BACKUP_CLONE\BACKUP_CLONE\_21_20150821_2JQF46C1_1_1 tag=TAG20150821T005108
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSTEM01.DBF
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\DILIP\ORADATA\BACKUP_CLONE\BACKUP_CLONE\_21_20150821_2IQF46BS_1_1
channel ORA_AUX_DISK_1: piece handle=C:\APP\DILIP\ORADATA\BACKUP_CLONE\BACKUP_CLONE\_21_20150821_2IQF46BS_1_1 tag=TAG20150821T005108
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 21-AUG-15
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST2" RESETLOGS ARCHIVELOG
  MAXLOGFILES     32
  MAXLOGMEMBERS      2
  MAXDATAFILES       32
  MAXINSTANCES    16
  MAXLOGHISTORY     1752
 LOGFILE
  GROUP  1 ( 'C:\APP\DILIP\ORADATA\backup_clone\test2\t_log1.f' ) SIZE 10 M ,
  GROUP  2 ( 'C:\APP\DILIP\ORADATA\backup_clone\test2\t_log2.f' ) SIZE 10 M
 DATAFILE
  'C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSTEM01.DBF'
 CHARACTER SET US7ASCII


contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=888284617 file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=888284617 file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF

contents of Memory Script:
{
   set until scn  325074;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 21-AUG-15
using channel ORA_AUX_DISK_1
datafile 4 not processed because file is offline
datafile 5 not processed because file is offline

starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file C:\APP\DILIP\PRODUCT\11.1.0\DB_1\RDBMS\ARC00003_0888274922.001
archived log file name=C:\APP\DILIP\PRODUCT\11.1.0\DB_1\RDBMS\ARC00003_0888274922.001 thread=1 sequence=3
media recovery complete, elapsed time: 00:00:01
Finished recover at 21-AUG-15

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     209235968 bytes

Fixed Size                     1332188 bytes
Variable Size                 71306276 bytes
Database Buffers             130023424 bytes
Redo Buffers                   6574080 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST2" RESETLOGS ARCHIVELOG
  MAXLOGFILES     32
  MAXLOGMEMBERS      2
  MAXDATAFILES       32
  MAXINSTANCES    16
  MAXLOGHISTORY     1752
 LOGFILE
  GROUP  1 ( 'C:\APP\DILIP\ORADATA\backup_clone\test2\t_log1.f' ) SIZE 10 M ,
  GROUP  2 ( 'C:\APP\DILIP\ORADATA\backup_clone\test2\t_log2.f' ) SIZE 10 M
 DATAFILE
  'C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSTEM01.DBF'
 CHARACTER SET US7ASCII


contents of Memory Script:
{
   set newname for tempfile  1 to
 "C:\APP\DILIP\ORADATA\backup_clone\test2\TEMP01.DBF";
   switch clone tempfile all;
   catalog clone datafilecopy  "C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF";
   catalog clone datafilecopy  "C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to C:\APP\DILIP\ORADATA\backup_clone\test2\TEMP01.DBF in control file

cataloged datafile copy
datafile copy file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF RECID=1 STAMP=888284634

cataloged datafile copy
datafile copy file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF RECID=2 STAMP=888284634

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=888284634 file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=888284634 file name=C:\APP\DILIP\ORADATA\BACKUP_CLONE\TEST2UNDOTBS01.DBF

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened

contents of Memory Script:
{
# drop offline and skipped tablespaces
sql clone 'drop tablespace  "TT1" including contents cascade constraints';
# drop offline and skipped tablespaces
sql clone 'drop tablespace  "TT" including contents cascade constraints';
}
executing Memory Script

sql statement: drop tablespace  "TT1" including contents cascade constraints

sql statement: drop tablespace  "TT" including contents cascade constraints
Finished Duplicate Db at 21-AUG-15

RMAN>


RMAN> exit

duplicate db---test2 no tt and tt1 tablespace.

SYS@test2> select name from v$tablespace;

NAME
------------------------------
SYSTEM
TEMP
SYSAUX
SYS_UNDOTS

4 rows selected.

No comments:

Post a Comment