Saturday, June 7, 2014

RMAN duplicate database using until clause and skip tablespace

1.script to perform RMAN duplicate using until clause and skip tablespace
run
{
allocate channel trgt1 device type disk connect 'sys/sys123@cvrman';
allocate channel trgt2 device type disk connect 'sys/sys123@cvrman';
allocate channel trgt3 device type disk connect 'sys/sys123@cvrman';
allocate auxiliary channel aux1 device type disk;
allocate auxiliary channel aux2 device type disk;
allocate auxiliary channel aux3 device type disk;
#set until time "to_date('06-jun-2014 23:04:10','dd-mon-yyyy hh24:mi:ss')";
set until sequence 15 thread 1;
duplicate target database to crman
spfile
set audit_file_dest='/u01/app/orcl/oracle/admin/crman/adump'
set dispatchers='(PROTOCOL=TCP) (SERVICE=crmanXDB)'
set control_files='+DATA','+DATA'
skip tablespace example;
release channel trgt1;
release channel trgt2;
release channel trgt3;
release channel aux1;
release channel aux2;
release channel aux3;
}

2.Execution of the script
rman target="sys/sys123@cvrman" auxiliary="sys/sys123@crman"

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jun 7 14:15:02 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CVRMAN (DBID=659771233)
connected to auxiliary database: CRMAN (not mounted)

RMAN> @ rman_duplicate_2.cmd

RMAN> run
2> {
3> allocate channel trgt1 device type disk connect *;
4> allocate channel trgt2 device type disk connect *;
5> allocate channel trgt3 device type disk connect *;
6> allocate auxiliary channel aux1 device type disk;
7> allocate auxiliary channel aux2 device type disk;
8> allocate auxiliary channel aux3 device type disk;
9> #set until time "to_date('06-jun-2014 23:04:10','dd-mon-yyyy hh24:mi:ss')";
10> set until sequence 15 thread 1;
11> duplicate target database to crman
12> spfile
13> set audit_file_dest='/u01/app/orcl/oracle/admin/crman/adump'
14> set dispatchers='(PROTOCOL=TCP) (SERVICE=crmanXDB)'
15> set control_files='+DATA','+DATA'
16> skip tablespace example;
17> release channel trgt1;
18> release channel trgt2;
19> release channel trgt3;
20> release channel aux1;
21> release channel aux2;
22> release channel aux3;
23> }
using target database control file instead of recovery catalog
allocated channel: trgt1
channel trgt1: SID=65 device type=DISK

allocated channel: trgt2
channel trgt2: SID=56 device type=DISK

allocated channel: trgt3
channel trgt3: SID=39 device type=DISK

allocated channel: aux1
channel aux1: SID=27 device type=DISK

allocated channel: aux2
channel aux2: SID=28 device type=DISK

allocated channel: aux3
channel aux3: SID=29 device type=DISK

executing command: SET until clause

Starting Duplicate Db at 07-JUN-14

contents of Memory Script:
{
   set until scn  1111338;
   restore clone spfile to  '/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfilecrman.ora';
   sql clone "alter system set spfile= ''/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfilecrman.ora''";
}
executing Memory Script

executing command: SET until clause

Starting restore at 07-JUN-14

WARNING: A restore time was estimated based on the supplied UNTIL SCN
channel aux1: starting datafile backup set restore
channel aux1: restoring SPFILE
output file name=/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfilecrman.ora
channel aux1: reading from backup piece +DATA/cvrman/backupset/2014_06_07/ncsnf0_tag20140607t123328_0.421.849616993
channel aux1: piece handle=+DATA/cvrman/backupset/2014_06_07/ncsnf0_tag20140607t123328_0.421.849616993 tag=TAG20140607T123328
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:14
Finished restore at 07-JUN-14

sql statement: alter system set spfile= ''/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfilecrman.ora''

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''CRMAN'' comment=
 ''duplicate'' scope=spfile";
   sql clone "alter system set  audit_file_dest =
 ''/u01/app/orcl/oracle/admin/crman/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  dispatchers =
 ''(PROTOCOL=TCP) (SERVICE=crmanXDB)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files =
 ''+DATA'', ''+DATA'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''CRMAN'' comment= ''duplicate'' scope=spfile

sql statement: alter system set  audit_file_dest =  ''/u01/app/orcl/oracle/admin/crman/adump'' comment= '''' scope=spfile

sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=crmanXDB)'' comment= '''' scope=spfile

sql statement: alter system set  control_files =  ''+DATA'', ''+DATA'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     275578880 bytes

Fixed Size                     2227584 bytes
Variable Size                113246848 bytes
Database Buffers             155189248 bytes
Redo Buffers                   4915200 bytes
allocated channel: aux1
channel aux1: SID=34 device type=DISK
allocated channel: aux2
channel aux2: SID=35 device type=DISK
allocated channel: aux3
channel aux3: SID=27 device type=DISK

contents of Memory Script:
{
   set until scn  1111338;
   sql clone "alter system set  control_files =
  ''+DATA/crman/controlfile/current.425.849622755'', ''+DATA/crman/controlfile/current.430.849622755'' comment=
 ''Set by RMAN'' scope=spfile";
   sql clone "alter system set  db_name =
 ''CVRMAN'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''CRMAN'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile;
   alter clone database mount;
}
executing Memory Script

executing command: SET until clause

sql statement: alter system set  control_files =   ''+DATA/crman/controlfile/current.425.849622755'', ''+DATA/crman/controlfile/current.430.849622755'' comment= ''Set by RMAN'' scope=spfile

sql statement: alter system set  db_name =  ''CVRMAN'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''CRMAN'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     275578880 bytes

Fixed Size                     2227584 bytes
Variable Size                117441152 bytes
Database Buffers             150994944 bytes
Redo Buffers                   4915200 bytes
allocated channel: aux1
channel aux1: SID=34 device type=DISK
allocated channel: aux2
channel aux2: SID=35 device type=DISK
allocated channel: aux3
channel aux3: SID=36 device type=DISK

Starting restore at 07-JUN-14

channel aux1: starting datafile backup set restore
channel aux1: restoring control file
channel aux1: reading from backup piece +DATA/cvrman/backupset/2014_06_07/ncsnf0_tag20140607t123328_0.421.849616993
channel aux1: piece handle=+DATA/cvrman/backupset/2014_06_07/ncsnf0_tag20140607t123328_0.421.849616993 tag=TAG20140607T123328
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:08
output file name=+DATA/crman/controlfile/current.425.849622755
output file name=+DATA/crman/controlfile/current.430.849622755
Finished restore at 07-JUN-14

database mounted
Checking that duplicated tablespaces are self-contained
The following materialized objects were found in skipped tablespaces
Materialized table CAL_MONTH_SALES_MV on tablespace EXAMPLE
Materialized table FWEEK_PSCAT_SALES_MV on tablespace EXAMPLE
Materialized index FWEEK_PSCAT_SALES_MV on tablespace EXAMPLE
Oracle instance started

Total System Global Area     275578880 bytes

Fixed Size                     2227584 bytes
Variable Size                117441152 bytes
Database Buffers             150994944 bytes
Redo Buffers                   4915200 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''CRMAN'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
}
executing Memory Script

sql statement: alter system set  db_name =  ''CRMAN'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile
...

No comments: