In Oracle 12c, a single table or a single partition of a partitioned table can be restored from an RMAN backup via the RECOVER TABLE command. Prior to 12c restoring a table was a long and time consuming process.
So what does the RMAN RECOVER TABLE command do behind the scenes?
It creates an auxiliary database or instance which is used to recover the tables to a specific point in time. This database will contain a few system related data files like SYSTEM, SYSAUX, UNDO and data files belonging to the tablespace containing the tables we are looking to restore.
In this example it restores SYSTEM,SYSAUX,UNDO tablespaces for CDB and SYSTEM and SYSAUX and EXAMPLE tablespace for PDB Then it creates a Data Pump export dump file which will contain the recovered table or partitions of tables. It will then import the data into the target database using Data Pump Import. Finally it will remove the temporary auxiliary instance.
Setup the test:
1) Create a user
SQL> connect / as sysdba
SQL> Alter session set container=PDB2
SQL> create user example identified by "example"
default tablespace users
temporary tablespace temp profile default;
SQL> grant create session, create table to example;
SQL> grant execute on dbms_flashback to example;
This user "example" is created in pluggable database PDB2.
2) Create a table for that user "example"
SQL> conn example/example@pdb2;
SQL> create table test_restore (col1 number);
Table created.
SQL> insert into test_restore values (1)
1 row created.
SQL> commit
Commit complete.
3) Take a full backup plus archivelogs:
$rman target /
RMAN> backup database plus archivelog;
4) Drop the table
SQL> alter session set container=pdb2;
Session altered.
SQL> desc example.test_restore;
Name Null? Type
------ -------- ----------------------------
COL1 NUMBER
SQL> select * from example.test_restore;
COL1
----------
1
SQL> select sysdate from dual;
SYSDATE
-------------------
10-10-2017 17:17:21
SQL> drop table example.test_restore;
Table dropped.
5) Restore the table:
The following script will do a point in time recovery, but you can also restore to an SCN, or to a sequence number also.
$ rman target /
RMAN> run {
recover table example.test_restore of pluggable database PDB2
until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')"
auxiliary destination '/u02/CDB2/aux';
}
Sample output:
$ rman target /
RMAN>
RMAN> run {
recover table example.test_restore of pluggable database PDB2
until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')"
auxiliary destination '/u02/CDB2/aux';
}
Starting recover at 10-OCT-17
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='TEST'
initialization parameters used for automatic instance:
db_name=CDB2
db_unique_name=TEST_pitr_PDB2_CDB2
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u02
_system_trig_enabled=FALSE
sga_target=1000M
processes=200
db_create_file_dest=/u02/CDB2/aux
log_archive_dest_1='location=/u02/CDB2/aux'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB2
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 10-OCT-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/product/12.1.0.2/dbs/c-600824249-20171010-01
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/product/12.1.0.2/dbs/c-600824249-20171010-01 tag=TAG20171010T171310
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl
Finished restore at 10-OCT-17
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 5 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 11 to new;
set newname for clone datafile 12 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 4 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 5, 3, 11, 12;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 4 to /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 10-OCT-17
using channel ORA_AUX_DISK_1
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 /u02/CDB2/aux/CDB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2ermd29r_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2ermd29r_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
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 00011 to /u02/CDB2/aux/CDB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2grmd2bn_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2grmd2bn_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 10-OCT-17
datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40pzm5q_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_d40pzm58_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40pzm5l_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=9 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40q108w_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=10 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40q108l_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 5 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB2' "alter database datafile
11 online";
sql clone 'PDB2' "alter database datafile
12 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB2":"SYSTEM", "PDB2":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 5 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 11 online
sql statement: alter database datafile 12 online
Starting recover at 10-OCT-17
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 339 is already on disk as file /u02/CDB2/arch/1_339_853777209.dbf
archived log for thread 1 with sequence 340 is already on disk as file /u02/CDB2/arch/1_340_853777209.dbf
archived log file name=/u02/CDB2/arch/1_339_853777209.dbf thread=1 sequence=339
archived log file name=/u02/CDB2/arch/1_340_853777209.dbf thread=1 sequence=340
media recovery complete, elapsed time: 00:00:00
Finished recover at 10-OCT-17
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDB2 open read only';
}
executing Memory Script
sql statement: alter pluggable database PDB2 open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl'' comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
sql statement: alter system set control_files = ''/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 13 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 13;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 10-OCT-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
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 00013 to /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2grmd2bn_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2grmd2bn_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 10-OCT-17
datafile 13 switched to datafile copy
input datafile copy RECID=12 STAMP=929467360 file name=/u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_d40q2yz2_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# online the datafiles restored or switched
sql clone 'PDB2' "alter database datafile
13 online";
# recover and open resetlogs
recover clone database tablespace "PDB2":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB2":"SYSTEM", "PDB2":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 13 online
Starting recover at 10-OCT-17
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 339 is already on disk as file /u02/CDB2/arch/1_339_853777209.dbf
archived log for thread 1 with sequence 340 is already on disk as file /u02/CDB2/arch/1_340_853777209.dbf
archived log file name=/u02/CDB2/arch/1_339_853777209.dbf thread=1 sequence=339
archived log file name=/u02/CDB2/arch/1_340_853777209.dbf thread=1 sequence=340
media recovery complete, elapsed time: 00:00:01
Finished recover at 10-OCT-17
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database PDB2 open';
}
executing Memory Script
sql statement: alter pluggable database PDB2 open
contents of Memory Script:
{
# create directory for datapump import
sql 'PDB2' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u02/CDB2/aux''";
# create directory for datapump export
sql clone 'PDB2' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u02/CDB2/aux''";
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u02/CDB2/aux''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u02/CDB2/aux''
Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_TEST_ymhe":
EXPDP> Estimate in progress using BLOCKS method...
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 64 KB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> . . exported "EXAMPLE"."TEST_RESTORE" 5.101 KB 5 rows
EXPDP> Master table "SYS"."TSPITR_EXP_TEST_ymhe" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_TEST_ymhe is:
EXPDP> /u02/CDB2/aux/tspitr_TEST_32949.dmp
EXPDP> Job "SYS"."TSPITR_EXP_TEST_ymhe" successfully completed at Thu Dec 1 17:23:10 2016 elapsed 0 00:00:19
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script
Oracle instance shut down
Performing import of tables...
IMPDP> Master table "SYS"."TSPITR_IMP_TEST_Cqnj" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_TEST_Cqnj":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
IMPDP> . . imported "EXAMPLE"."TEST_RESTORE" 5.101 KB 5 rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYS"."TSPITR_IMP_TEST_Cqnj" successfully completed at Thu Dec 1 17:23:18 2016 elapsed 0 00:00:03
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_d40q1llw_.tmp deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_d40q1k5g_.tmp deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_3_d40q32mo_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_2_d40q31v7_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_1_d40q314c_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_d40q2yz2_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40q108l_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40q108w_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40pzm5l_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_d40pzm58_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40pzm5q_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl deleted
auxiliary instance file tspitr_TEST_32949.dmp deleted
Finished recover at 10-OCT-17
RMAN>
6) Check that the table has been restored
SQL> alter session set container=PDB2;
Session altered.
SQL> select * from example.test_restore;
COL1
----------
1
Caution: Tables cannot be restored in the SYS schema.You can’t restore a table that hasn’t been backed up, even if it exists in current archive logs.
So what does the RMAN RECOVER TABLE command do behind the scenes?
It creates an auxiliary database or instance which is used to recover the tables to a specific point in time. This database will contain a few system related data files like SYSTEM, SYSAUX, UNDO and data files belonging to the tablespace containing the tables we are looking to restore.
In this example it restores SYSTEM,SYSAUX,UNDO tablespaces for CDB and SYSTEM and SYSAUX and EXAMPLE tablespace for PDB Then it creates a Data Pump export dump file which will contain the recovered table or partitions of tables. It will then import the data into the target database using Data Pump Import. Finally it will remove the temporary auxiliary instance.
Setup the test:
1) Create a user
SQL> connect / as sysdba
SQL> Alter session set container=PDB2
SQL> create user example identified by "example"
default tablespace users
temporary tablespace temp profile default;
SQL> grant create session, create table to example;
SQL> grant execute on dbms_flashback to example;
This user "example" is created in pluggable database PDB2.
2) Create a table for that user "example"
SQL> conn example/example@pdb2;
SQL> create table test_restore (col1 number);
Table created.
SQL> insert into test_restore values (1)
1 row created.
SQL> commit
Commit complete.
3) Take a full backup plus archivelogs:
$rman target /
RMAN> backup database plus archivelog;
4) Drop the table
SQL> alter session set container=pdb2;
Session altered.
SQL> desc example.test_restore;
Name Null? Type
------ -------- ----------------------------
COL1 NUMBER
SQL> select * from example.test_restore;
COL1
----------
1
SQL> select sysdate from dual;
SYSDATE
-------------------
10-10-2017 17:17:21
SQL> drop table example.test_restore;
Table dropped.
5) Restore the table:
The following script will do a point in time recovery, but you can also restore to an SCN, or to a sequence number also.
$ rman target /
RMAN> run {
recover table example.test_restore of pluggable database PDB2
until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')"
auxiliary destination '/u02/CDB2/aux';
}
Sample output:
$ rman target /
RMAN>
RMAN> run {
recover table example.test_restore of pluggable database PDB2
until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')"
auxiliary destination '/u02/CDB2/aux';
}
Starting recover at 10-OCT-17
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='TEST'
initialization parameters used for automatic instance:
db_name=CDB2
db_unique_name=TEST_pitr_PDB2_CDB2
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u02
_system_trig_enabled=FALSE
sga_target=1000M
processes=200
db_create_file_dest=/u02/CDB2/aux
log_archive_dest_1='location=/u02/CDB2/aux'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB2
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 10-OCT-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/product/12.1.0.2/dbs/c-600824249-20171010-01
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/product/12.1.0.2/dbs/c-600824249-20171010-01 tag=TAG20171010T171310
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl
Finished restore at 10-OCT-17
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 5 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 11 to new;
set newname for clone datafile 12 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 4 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 5, 3, 11, 12;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 4 to /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 10-OCT-17
using channel ORA_AUX_DISK_1
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 /u02/CDB2/aux/CDB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2ermd29r_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2ermd29r_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
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 00011 to /u02/CDB2/aux/CDB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2grmd2bn_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2grmd2bn_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 10-OCT-17
datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40pzm5q_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_d40pzm58_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40pzm5l_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=9 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40q108w_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=10 STAMP=929467311 file name=/u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40q108l_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 5 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB2' "alter database datafile
11 online";
sql clone 'PDB2' "alter database datafile
12 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB2":"SYSTEM", "PDB2":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 5 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 11 online
sql statement: alter database datafile 12 online
Starting recover at 10-OCT-17
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 339 is already on disk as file /u02/CDB2/arch/1_339_853777209.dbf
archived log for thread 1 with sequence 340 is already on disk as file /u02/CDB2/arch/1_340_853777209.dbf
archived log file name=/u02/CDB2/arch/1_339_853777209.dbf thread=1 sequence=339
archived log file name=/u02/CDB2/arch/1_340_853777209.dbf thread=1 sequence=340
media recovery complete, elapsed time: 00:00:00
Finished recover at 10-OCT-17
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDB2 open read only';
}
executing Memory Script
sql statement: alter pluggable database PDB2 open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl'' comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
sql statement: alter system set control_files = ''/u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1048576000 bytes
Fixed Size 2932336 bytes
Variable Size 276824464 bytes
Database Buffers 763363328 bytes
Redo Buffers 5455872 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 13 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 13;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 10-OCT-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK
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 00013 to /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/CDB2/arch/backup_2grmd2bn_1_1
channel ORA_AUX_DISK_1: piece handle=/u02/CDB2/arch/backup_2grmd2bn_1_1 tag=TAG20171010T171123
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 10-OCT-17
datafile 13 switched to datafile copy
input datafile copy RECID=12 STAMP=929467360 file name=/u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_d40q2yz2_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('10-10-2017 17:16:00','mm/dd/yyyy hh24:mi:ss')";
# online the datafiles restored or switched
sql clone 'PDB2' "alter database datafile
13 online";
# recover and open resetlogs
recover clone database tablespace "PDB2":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB2":"SYSTEM", "PDB2":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 13 online
Starting recover at 10-OCT-17
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 339 is already on disk as file /u02/CDB2/arch/1_339_853777209.dbf
archived log for thread 1 with sequence 340 is already on disk as file /u02/CDB2/arch/1_340_853777209.dbf
archived log file name=/u02/CDB2/arch/1_339_853777209.dbf thread=1 sequence=339
archived log file name=/u02/CDB2/arch/1_340_853777209.dbf thread=1 sequence=340
media recovery complete, elapsed time: 00:00:01
Finished recover at 10-OCT-17
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database PDB2 open';
}
executing Memory Script
sql statement: alter pluggable database PDB2 open
contents of Memory Script:
{
# create directory for datapump import
sql 'PDB2' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u02/CDB2/aux''";
# create directory for datapump export
sql clone 'PDB2' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u02/CDB2/aux''";
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u02/CDB2/aux''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u02/CDB2/aux''
Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_TEST_ymhe":
EXPDP> Estimate in progress using BLOCKS method...
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 64 KB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> . . exported "EXAMPLE"."TEST_RESTORE" 5.101 KB 5 rows
EXPDP> Master table "SYS"."TSPITR_EXP_TEST_ymhe" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_TEST_ymhe is:
EXPDP> /u02/CDB2/aux/tspitr_TEST_32949.dmp
EXPDP> Job "SYS"."TSPITR_EXP_TEST_ymhe" successfully completed at Thu Dec 1 17:23:10 2016 elapsed 0 00:00:19
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script
Oracle instance shut down
Performing import of tables...
IMPDP> Master table "SYS"."TSPITR_IMP_TEST_Cqnj" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_TEST_Cqnj":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
IMPDP> . . imported "EXAMPLE"."TEST_RESTORE" 5.101 KB 5 rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYS"."TSPITR_IMP_TEST_Cqnj" successfully completed at Thu Dec 1 17:23:18 2016 elapsed 0 00:00:03
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_d40q1llw_.tmp deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_temp_d40q1k5g_.tmp deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_3_d40q32mo_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_2_d40q31v7_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/onlinelog/o1_mf_1_d40q314c_.log deleted
auxiliary instance file /u02/CDB2/aux/TEST_PITR_PDB2_CDB2/datafile/o1_mf_users_d40q2yz2_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40q108l_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40q108w_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_sysaux_d40pzm5l_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_undotbs1_d40pzm58_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/datafile/o1_mf_system_d40pzm5q_.dbf deleted
auxiliary instance file /u02/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl deleted
auxiliary instance file tspitr_TEST_32949.dmp deleted
Finished recover at 10-OCT-17
RMAN>
6) Check that the table has been restored
SQL> alter session set container=PDB2;
Session altered.
SQL> select * from example.test_restore;
COL1
----------
1
Caution: Tables cannot be restored in the SYS schema.You can’t restore a table that hasn’t been backed up, even if it exists in current archive logs.
Thanks!, What happens with the PK, FK and UK?
ReplyDeletehi
ReplyDeleteI followed this doc...but getting space issue on the log...the auxiliary dest has enough space...which space its complaining about?
----- PL/SQL Call Stack -----
object line object
handle number name
0x72324c60 32239 package body SYS.KUPW$WORKER.WRITE_ERROR_INFORMATION
0x72324c60 12119 package body SYS.KUPW$WORKER.DETERMINE_FATAL_ERROR
0x72324c60 9608 package body SYS.KUPW$WORKER.CONFIGURE_METADATA_UNLOAD
0x72324c60 3611 package body SYS.KUPW$WORKER.UNLOAD_METADATA
0x72324c60 13063 package body SYS.KUPW$WORKER.DISPATCH_WORK_ITEMS
0x72324c60 2311 package body SYS.KUPW$WORKER.MAIN
0x723284b0 2 anonymous block
DBMS_LOB.CREATETEMPORARY v_dml_xml_clob
DBMS_LOB.CREATETEMPORARY v_dml_xml_clob
Flags: 129
Start sequence number:
End sequence number:
**NOT** Doing Parallel metadata
In procedure CONFIGURE_METADATA_UNLOAD
Phase: Filter Name: BEGIN_AFTER Filter Value:
DBMS_METADATA.OPEN12.2.0.1.0
In procedure DETERMINE_FATAL_ERROR with ORA-04063: package body "SYS.DBMS_METADATA" has errors
ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_METADATA"
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /bkp_clouds2z031/h2huat02/H2HUAT02_RDX02/datafile/o1_mf_temp__4khy5z2d_.tmp deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/UCVD_PITR_H2HUAT02/onlinelog/o1_mf_2__4ko90rot_.log deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/UCVD_PITR_H2HUAT02/onlinelog/o1_mf_1__4ko8y90k_.log deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/UCVD_PITR_H2HUAT02/datafile/o1_mf_profile___4knhj54c_.dbf deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/H2HUAT02_RDX02/datafile/o1_mf_sysaux__4fgb0ym8_.dbf deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/H2HUAT02_RDX02/datafile/o1_mf_undotbs1__4fg9wdbn_.dbf deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/H2HUAT02_RDX02/datafile/o1_mf_system__4fg9od11_.dbf deleted
auxiliary instance file /bkp_clouds2z031/h2huat02/H2HUAT02_RDX02/controlfile/o1_mf__4fg17kkj_.ctl deleted
auxiliary instance file tspitr_ucvD_73793.dmp deleted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/18/2021 11:00:10
RMAN-06962: Error received during export of metadata
RMAN-06965: Datapump job has stopped
RMAN-06960: EXPDP> Job "SYS"."TSPITR_EXP_ucvD_qFry" stopped due to fatal error at Tue May 18 11:00:03 2021 elapsed 0 00:00:07
RMAN-05122: there is insufficient disk space to perform this table recovery
RMAN-05122: there is insufficient disk space to perform this table recovery
online backup statistics
ReplyDeleteOnline Daily Backup software helps you to create copies of files, database, and hard drive that prevents your data loss. Click here for more information about Online Cloud Backup Reseller Program.
TRUMP WON ! ! ! ! !
ReplyDelete