Recover Table using RMAN / Oracle Database 12c


[oracle@anar12cdb ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Dec 4 20:41:25 2015
Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved.
connected to target database: KBAZERDB (DBID=2818129616)
RMAN> backup database test;
Starting backup at 04-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/u01/app/oracle/oradata/KBAZERDB/test/sysaux01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/KBAZERDB/test/example01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/KBAZERDB/test/system01.dbf
input datafile file number=00010 name=/u01/app/oracle/oradata/KBAZERDB/test/SAMPLE_SCHEMA_users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-15
channel ORA_DISK_1: finished piece 1 at 04-DEC-15
piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/EC8587CDE0150D19E043C906A8C0B994/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T204133_99y8qy4k_.bkp tag=TAG20151204T204133 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 04-DEC-15
Starting Control File and SPFILE Autobackup at 04-DEC-15
piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/autobackup/2015_12_04/o1_mf_s_833316139_99y8scgp_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 04-DEC-15
RMAN> exit
[oracle@anar12cdb ~]$ sqlplus hr/hr@localhost:1521/test
SQL*Plus: Release 12.1.0.1.0 Production on Wed Dec 4 20:43:07 2015
Copyright (c) 1982, 2015, Oracle. All rights reserved.
Last Successful login time: Sat May 25 2015 04:22:56 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> truncate table debug_anar;
Table truncated.
[oracle@anar12cdb ~]$ export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
[oracle@anar12cdb ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Dec 4 21:17:27 2015
Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved.
connected to target database: KBAZERDB (DBID=2818129616)
RMAN> recover table hr.debug_anar of pluggable database test until time "to_date('04-dec 20:43:07','dd-mon hh24:mi:ss')"
2> auxiliary destination '/tmp' remap table hr.debug_anar:debug_anar_restored;
Starting recover at 04-DEC-2015 21:19:10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 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='CEee'
initialization parameters used for automatic instance:
db_name=KBAZERDB
db_unique_name=CEee_pitr_test_KBAZERDB
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_create_file_dest=/tmp
log_archive_dest_1='location=/tmp'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance KBAZERDB
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 281019648 bytes
Database Buffers 780140544 bytes
Redo Buffers 5480448 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('04-dec 20:43:07','dd-mon 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 04-DEC-2015 21:19:17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 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/fast_recovery_area/KBAZERDB/autobackup/2015_12_04/o1_mf_s_833316139_99y8scgp_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/autobackup/2015_12_04/o1_mf_s_833316139_99y8scgp_.bkp tag=TAG20151204T204219
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/tmp/KBAZERDB/controlfile/o1_mf_99ybyp57_.ctl
Finished restore at 04-DEC-2015 21:19:19
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('04-dec 20:43:07','dd-mon 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 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 8 to new;
set newname for clone datafile 9 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 8, 9;
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 /tmp/KBAZERDB/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /tmp/KBAZERDB/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 04-DEC-2015 21:19:23
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 /tmp/KBAZERDB/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/KBAZERDB/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/KBAZERDB/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/KBAZERDB/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T203105_99y849k3_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T203105_99y849k3_.bkp tag=TAG20151204T203105
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:57
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 00008 to /tmp/KBAZERDB/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /tmp/KBAZERDB/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/KBAZERDB/EC8587CDE0150D19E043C906A8C0B994/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T204133_99y8qy4k_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/EC8587CDE0150D19E043C906A8C0B994/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T204133_99y8qy4k_.bkp tag=TAG20151204T204133
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 04-DEC-2015 21:20:45
datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=833318445 file name=/tmp/KBAZERDB/datafile/o1_mf_system_99ybyvx8_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=833318445 file name=/tmp/KBAZERDB/datafile/o1_mf_undotbs1_99ybyvy0_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=14 STAMP=833318445 file name=/tmp/KBAZERDB/datafile/o1_mf_sysaux_99ybyvxw_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=15 STAMP=833318445 file name=/tmp/KBAZERDB/datafile/o1_mf_system_99yc0nj2_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=16 STAMP=833318445 file name=/tmp/KBAZERDB/datafile/o1_mf_sysaux_99yc0nhg_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('04-dec 20:43:07','dd-mon hh24:mi:ss')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
sql clone 'test' "alter database datafile
 8 online";
sql clone 'test' "alter database datafile
 9 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "test":"SYSTEM", "test":"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 4 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 8 online
sql statement: alter database datafile 9 online
Starting recover at 04-DEC-2015 21:20:45
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 15 is already on disk as file /u01/app/oracle/fast_recovery_area/KBAZERDB/archivelog/2015_12_04/o1_mf_1_15_99y90sr7_.arc
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=14
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/KBAZERDB/backupset/2015_12_04/o1_mf_annnn_TAG20151204T203240_99y87926_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/backupset/2015_12_04/o1_mf_annnn_TAG20151204T203240_99y87926_.bkp tag=TAG20151204T203240
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/tmp/1_14_833108818.dbf thread=1 sequence=14
archived log file name=/u01/app/oracle/fast_recovery_area/KBAZERDB/archivelog/2015_12_04/o1_mf_1_15_99y90sr7_.arc thread=1 sequence=15
media recovery complete, elapsed time: 00:00:01
Finished recover at 04-DEC-2015 21:20:48
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database test open read only';
}
executing Memory Script
sql statement: alter pluggable database test 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 =
 ''/tmp/KBAZERDB/controlfile/o1_mf_99ybyp57_.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 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter system set control_files = ''/tmp/KBAZERDB/controlfile/o1_mf_99ybyp57_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('04-dec 20:43:07','dd-mon hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 11 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 11;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 04-DEC-2015 21:21:13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 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 00011 to /tmp/CEEE_PITR_test_KBAZERDB/datafile/o1_mf_example_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/KBAZERDB/EC8587CDE0150D19E043C906A8C0B994/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T204133_99y8qy4k_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/KBAZERDB/EC8587CDE0150D19E043C906A8C0B994/backupset/2015_12_04/o1_mf_nnndf_TAG20151204T204133_99y8qy4k_.bkp tag=TAG20151204T204133
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 04-DEC-2015 21:21:28
datafile 11 switched to datafile copy
input datafile copy RECID=18 STAMP=833318488 file name=/tmp/CEEE_PITR_test_KBAZERDB/datafile/o1_mf_example_99yc29jc_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('04-dec 20:43:07','dd-mon hh24:mi:ss')";
# online the datafiles restored or switched
sql clone 'test' "alter database datafile
 11 online";
# recover and open resetlogs
recover clone database tablespace "test":"EXAMPLE", "SYSTEM", "UNDOTBS1", "SYSAUX", "test":"SYSTEM", "test":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 11 online
Starting recover at 04-DEC-2015 21:21:28
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 15 is already on disk as file /u01/app/oracle/fast_recovery_area/KBAZERDB/archivelog/2015_12_04/o1_mf_1_15_99y90sr7_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/KBAZERDB/archivelog/2015_12_04/o1_mf_1_15_99y90sr7_.arc thread=1 sequence=15
media recovery complete, elapsed time: 00:00:00
Finished recover at 04-DEC-2015 21:21:29
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database test open';
}
executing Memory Script
sql statement: alter pluggable database test open
contents of Memory Script:
{
# create directory for datapump import
sql 'test' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/tmp''";
# create directory for datapump export
sql clone 'test' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/tmp''";
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp''
Performing export of tables...
 EXPDP> Starting "SYS"."TSPITR_EXP_CEee_uCuC":
 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 "HR"."debug_anar" 17.07 KB 107 rows
 EXPDP> Master table "SYS"."TSPITR_EXP_CEee_uCuC" successfully loaded/unloaded
 EXPDP> ******************************************************************************
 EXPDP> Dump file set for SYS.TSPITR_EXP_CEee_uCuC is:
 EXPDP> /tmp/tspitr_CEee_70300.dmp
 EXPDP> Job "SYS"."TSPITR_EXP_CEee_uCuC" successfully completed at Wed Dec 4 21:22:14 2015 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_CEee_yigA" successfully loaded/unloaded
 IMPDP> Starting "SYS"."TSPITR_IMP_CEee_yigA":
 IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
 IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
 IMPDP> . . imported "HR"."debug_anar_RESTORED" 17.07 KB 107 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_CEee_yigA" successfully completed at Wed Dec 4 21:22:33 2015 elapsed 0 00:00:13
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_temp_99yc1py4_.tmp deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_temp_99yc1kdl_.tmp deleted
auxiliary instance file /tmp/CEEE_PITR_test_KBAZERDB/onlinelog/o1_mf_3_99yc2tmo_.log deleted
auxiliary instance file /tmp/CEEE_PITR_test_KBAZERDB/onlinelog/o1_mf_2_99yc2sr7_.log deleted
auxiliary instance file /tmp/CEEE_PITR_test_KBAZERDB/onlinelog/o1_mf_1_99yc2sc8_.log deleted
auxiliary instance file /tmp/CEEE_PITR_test_KBAZERDB/datafile/o1_mf_example_99yc29jc_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_sysaux_99yc0nhg_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_system_99yc0nj2_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_sysaux_99ybyvxw_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_undotbs1_99ybyvy0_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/datafile/o1_mf_system_99ybyvx8_.dbf deleted
auxiliary instance file /tmp/KBAZERDB/controlfile/o1_mf_99ybyp57_.ctl deleted
auxiliary instance file tspitr_CEee_70300.dmp deleted
Finished recover at 04-DEC-2015 21:22:35
RMAN> quit
[oracle@anar12cdb ~]$ rman target sys/password@localhost:1521/test
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Dec 4 21:23:17 2015
Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved.
connected to target database: KBAZERDB (DBID=2818129616)
RMAN> select count(*) from hr.debug_anar_restored;
using target database control file instead of recovery catalog
COUNT(*)
----------
 107
RMAN> exit
Recovery Manager complete.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: