You are on page 1of 13

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

TABLESPACE POINT- IN - TIME RECOVERY TSPITR


TSPITR is one of the 11gR2 feature of the oracle database. In earlier versions of oracle we could
NOT recover a dropped tablespace using tablespace point in time recovery without affecting the
database. We have some limitations in earlier versions of oracle to perform TSPITR.
Lets say yesterday someone accidently dropped a tablespace or important object, but morning only
informed to you. During this time some others did many activities in the same database. Bringing
back the database to the particular time is really BAD choice. In this case, you have to perform
tablespace point in time recovery.
Tablespace Point-In-Time Recovery (generally abbreviated as TSPITR) is used to recovery of all
datafiles in a tablespace to a specific point in time. TSPITR is using transportable tablespace
functionality to restore one or more tablespace(s) to an earlier time without affecting rest of
the tablespaces and objects in the database by RMAN. Lets see how to restore & recover dropped
tablespace in a specific time.
RMAN carries out following steps to perform TSPITR
RMAN automatically creates and start the auxiliary instance and assigning random SID. It takes the
tablespace offline to be recovered in the target database.
It restores a backup control file from backup of the target database to the auxiliary instance
according to the TIME/SCN value specified in the UNTIL clause of the recover tablespace command.
Next it restores datafiles of the system, undo tablespaces with the datafiles of the recovered
tablespace from backup to the auxiliary destination.
RMAN first performs a recovery of the tablespace on the auxiliary instance and then recovers the
restored datafiles to a specified time. Opens the auxiliary database with RESETLOGS option.
TSPITR is used Datapump and Transportable Tablespace technology to extract and import the tablespace
metadata into the original target database.
First exports metadata of the recovered tablespace from the auxiliary instance to a dumpfile and
Shuts down the auxiliary instance. Next it imports the metadata of objects in the recovered
tablespace to the target database.
Now RMAN makes the restored tablespace as read/write and will take it offline. Finally removes the
auxiliary instance and delete all files associated with it.

LIMITATIONS AND RESTRICTIONS OF TSPITR


Cannot perform TSPITR (If archived redo logs are not avail).
Cannot perform TSPITR If database runs in NO ARCHIVELOG MODE.
Cannot use TSPITR to recover objects owned by SYS.
Cannot perform TSPITR on current default tablespace of the database.
Any tablespace with replicated master tables cannot be recovered with TSPITR. TSPITR does NOT
recover query optimizer statistics for recovered objects, as a DBA you must gather new statistics.
Once you have completed TSPITR on the tablespace, all previous backups of that tablespace are no
longer usable. So you should backup the tablespace after TSPITR has performed.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

Before starting to perform TSPITR, we should check the relationship between objects of the recovered
tablespace and objects of the different tablespaces which will not be recovered.
Make sure objects in the tablespace are self-contained.
Lets say we have the tablesapace called CRMS. It contains table TAB1 but indexes on that table
resides on another tablespace called HRMS. In this case, if you want to recover CRMS tablespace
to some point-in-time, then you must recover HRMS tablespace to the same point in time otherwise
you will lose indexes.
Lets start automatic TSPITR. I am NOT using recovery catalog.
CREATE TABLESPACES , USER , TABLE & INDEX
SYS> create tablespace crms datafile
'/u02/app/oracle/oradata/crms/crms01.dbf' size 100m;
Tablespace created.
SYS> alter tablespace crms add datafile
'/u02/app/oracle/oradata/crms/crms02.dbf' size 100m;
Tablespace altered.
SYS> create tablespace hrms datafile
'/u02/app/oracle/oradata/crms/hrms01.dbf' size 100m;
Tablespace created.
SYS> alter tablespace hrms add datafile
'/u02/app/oracle/oradata/crms/hrms02.dbf' size 100m;
Tablespace altered.
SYS> create user sony identified by sony default tablespace crms;
User created.
SYS> grant connect, resource to sony;
Grant succeeded.
SONY> create table tab1(id number , name varchar2(15), gender varchar2(6), salary number);
Table created.
SONY> alter table tab1 modify(id number constraint cons1_pkey primary key);
Table altered.
SONY> create index TAB1_GENDER_INDX1 on tab1(gender) tablespace hrms;
Index created.
SONY> select table_name, index_name, tablespace_name from
TABLE_NAME
-----------

INDEX_NAME

TABLESPACE_NAME

------------

----------------

TAB1

CONS1_PKEY

CRMS

TAB1

TAB1_GENDER_INDX1

HRMS

user_indexes;

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

TAKE THE FRESH BACKUP OF DATABASE


$ rlrman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sun Apr 12 11:20:15 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates.

All rights reserved.

connected to target database: CRMS (DBID=1570419964)


RMAN> backup database plus archivelog;
Starting backup at 12-APR-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=70 RECID=443 STAMP=876828403
channel ORA_DISK_1: starting piece 1 at 12-APR-15
channel ORA_DISK_1: finished piece 1 at 12-APR-15
piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_annnn_TAG20150412T
112643_bln28v7y_.bkp tag=TAG20150412T112643 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-APR-15
Starting backup at 12-APR-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u02/app/oracle/oradata/crms/undotbs01.dbf
input datafile file number=00001 name=/u02/app/oracle/oradata/crms/system01.dbf
input datafile file number=00002 name=/u02/app/oracle/oradata/crms/sysaux01.dbf
input datafile file number=00004 name=/u02/app/oracle/oradata/crms/users01.dbf
input datafile file number=00005 name=/u02/app/oracle/oradata/crms/crms01.dbf
input datafile file number=00006 name=/u02/app/oracle/oradata/crms/hrms01.dbf
input datafile file number=00007 name=/u02/app/oracle/oradata/crms/crms02.dbf
input datafile file number=00014 name=/u02/app/oracle/oradata/crms/hrms02.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-15
channel ORA_DISK_1: finished piece 1 at 12-APR-15
piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_nnndf_TAG20150412T
112644_bln28wls_.bkp tag=TAG20150412T112644 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 12-APR-15
channel ORA_DISK_1: finished piece 1 at 12-APR-15

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_ncsnf_TAG20150412T
112644_bln2bbsp_.bkp tag=TAG20150412T112644 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-APR-15
Starting backup at 12-APR-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=71 RECID=444 STAMP=876828452
channel ORA_DISK_1: starting piece 1 at 12-APR-15
channel ORA_DISK_1: finished piece 1 at 12-APR-15
piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_annnn_TAG20150412T
112732_bln2bd6s_.bkp tag=TAG20150412T112732 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-APR-15
CREATE SOME TABLES IN SONY USER
SONY> create table tab2 as select * from tab1;
Table created.
SONY> create table tab3 as select * from tab1;
Table created.
SONY> create index tab3_gender_indx1 on tab3(gender) tablespace users;
Index created.
SONY> select index_name, table_name, tablespace_name from user_indexes;
INDEX_NAME

TABLE_NAME

TABLESPACE_NAME

-------------------- ----------- --------------------------TAB3_GENDER_INDX1

TAB3

USERS

CONS1_PKEY

TAB1

CRMS

TAB1_GENDER_INDX1

TAB1

HRMS

CREARE NEW TABLE IN SYSTEM TABLESPACE


SONY> create table tab4(a date) tablespace system;
Table created.
SONY> insert into tab4 values(sysdate);
1 row created.
SONY> insert into tab4 values(sysdate);
1 row created.
SONY> commit;
Commit complete.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

SONY>select table_name, tablespace_name from user_tables;


TABLE_NAME

TABLESPACE_NAME

------------------------------ -----------------------------TAB1

CRMS

TAB3

CRMS

TAB2

CRMS

TAB4

SYSTEM

NOTE SCN & TIMEATAMP BEFORE DROP


SYS> select to_char(sysdate,'dd-mm-yy hh24:mi:ss')"SYSDATE" from dual;
SYSDATE
----------------12-04-15 12:18:40
SYS> select current_scn from v$database;
CURRENT_SCN
----------3944869
DROP SONY SCHEMA OBJECTS AND TABLESPACE (CRMS)
SYS> drop table sony.tab1;
Table dropped.
SYS> drop table sony.tab2;
Table dropped.
SYS> drop table sony.tab3;
Table dropped.
SYS> drop table sony.tab4;
Table dropped.
SYS> drop tablespace crms including contents and datafiles;
Tablespace dropped.

IDENTIFY THE DROP TIME FROM ALERT LOG


$ tail -f /u02/app/oracle/diag/rdbms/crms/crms/trace/alert_crms.log
Sun Apr 12 12:21:29 2015
drop tablespace crms including contents and datafiles
Deleted file /u02/app/oracle/oradata/crms/crms01.dbf
Deleted file /u02/app/oracle/oradata/crms/crms02.dbf
Completed: drop tablespace crms including contents and datafiles
We can use UNTIL SCN/TIME clause to recover dropped tablespace. Example for UNTIL SCN clause.
RMAN> recover tablespace "CRMS", "HRMS" until SCN 3944869 auxiliary destination '/u01';

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

Starting TSPITR using until time clause.


RMAN> recover tablespace "CRMS", "HRMS" until TIME
"to_date('12-04-15 12:18:40','DD-MM-YY HH24:MI:SS')" auxiliary destination '/u01';
Starting recover at 12-APR-15
using channel ORA_DISK_1
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='tjmt'
initialization parameters used for automatic instance:
db_name=CRMS
db_unique_name=tjmt_tspitr_CRMS
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=/u01
log_archive_dest_1='location=/u01'
#No auxiliary parameter file used
starting up automatic instance CRMS
Oracle instance started
Total System Global Area
Fixed Size

292933632 bytes
1336092 bytes

Variable Size

100666596 bytes

Database Buffers

184549376 bytes

Redo Buffers

6381568 bytes

Automatic instance created


List of tablespaces that have been dropped from the target database:
Tablespace CRMS
contents of Memory Script:
{
# set requested point in time
set until

time "to_date('12-04-15 12:18:40','DD-MM-YY 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';

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

# avoid unnecessary autobackups for structural changes during TSPITR


sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 12-APR-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 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
/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_ncsnf_TAG20150412T112644_
bln2bbsp_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_ncsnf_TAG20150412T
112644_bln2bbsp_.bkp tag=TAG20150412T112644
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/CRMS/controlfile/o1_mf_bln6dhz6_.ctl
Finished restore at 12-APR-15
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
contents of Memory Script:
{
# set requested point in time
set until

time "to_date('12-04-15 12:18:40','DD-MM-YY HH24:MI:SS')";

plsql <<<-- tspitr_2


declare
sqlstatement

varchar2(512);

offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '||

'"HRMS"' ||' offline immediate';

krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement);
exception
when offline_not_needed then
null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile

1 to new;

set newname for clone datafile

3 to new;

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

set newname for clone datafile

2 to new;

set newname for clone tempfile

1 to new;

set newname for datafile

6 to

"/u02/app/oracle/oradata/crms/hrms01.dbf";
set newname for datafile

14 to

"/u02/app/oracle/oradata/crms/hrms02.dbf";
set newname for datafile

5 to

"/u02/app/oracle/oradata/crms/crms01.dbf";
set newname for datafile

7 to

"/u02/app/oracle/oradata/crms/crms02.dbf";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile

1, 3, 2, 6, 14, 5, 7;

switch clone datafile all;


}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace "HRMS" offline immediate
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
executing command: SET NEWNAME
renamed tempfile 1 to /u01/CRMS/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 12-APR-15
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 /u01/CRMS/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/CRMS/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/CRMS/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u02/app/oracle/oradata/crms/hrms01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u02/app/oracle/oradata/crms/hrms02.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u02/app/oracle/oradata/crms/crms01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u02/app/oracle/oradata/crms/crms02.dbf

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

channel ORA_AUX_DISK_1: reading from backup piece


/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_nnndf_TAG20150412T112644_
bln28wls_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_nnndf_TAG20150412T
112644_bln28wls_.bkp tag=TAG20150412T112644
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:56
Finished restore at 12-APR-15

datafile 1 switched to datafile copy


input datafile copy RECID=230 STAMP=876832798 file
name=/u01/CRMS/datafile/o1_mf_system_bln6dpxl_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=231 STAMP=876832798 file
name=/u01/CRMS/datafile/o1_mf_undotbs1_bln6dpwg_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=232 STAMP=876832798 file
name=/u01/CRMS/datafile/o1_mf_sysaux_bln6dpyh_.dbf
contents of Memory Script:
{
# set requested point in time
set until

time "to_date('12-04-15 12:18:40','DD-MM-YY HH24:MI:SS')";

# online the datafiles restored or switched


sql clone "alter database datafile

1 online";

sql clone "alter database datafile

3 online";

sql clone "alter database datafile

2 online";

sql clone "alter database datafile

6 online";

sql clone "alter database datafile

14 online";

sql clone "alter database datafile

5 online";

sql clone "alter database datafile

7 online";

# recover and open resetlogs


recover clone database tablespace

"CRMS", "HRMS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete

archivelog;
alter clone database open resetlogs;
}

executing Memory Script


executing command: SET until clause
sql statement: alter database datafile

1 online

sql statement: alter database datafile

3 online

sql statement: alter database datafile

2 online

sql statement: alter database datafile

6 online

sql statement: alter database datafile

14 online

sql statement: alter database datafile

5 online

sql statement: alter database datafile

7 online

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

Starting recover at 12-APR-15


using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 71 is already on disk as file
/u02/app/oracle/flash_recovery_area/CRMS/archivelog/2015_04_12/o1_mf_1_71_bln2bd0q_.arc
archived log for thread 1 with sequence 72 is already on disk as file
/u02/app/oracle/flash_recovery_area/CRMS/archivelog/2015_04_12/o1_mf_1_72_bln6domy_.arc
archived log file
name=/u02/app/oracle/flash_recovery_area/CRMS/archivelog/2015_04_12/o1_mf_1_71_bln2bd0q_.arc
thread=1 sequence=71
archived log file
name=/u02/app/oracle/flash_recovery_area/CRMS/archivelog/2015_04_12/o1_mf_1_72_bln6domy_.arc
thread=1 sequence=72
media recovery complete, elapsed time: 00:00:04
Finished recover at 12-APR-15
database opened
contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace

"CRMS" read only';

sql clone 'alter tablespace

"HRMS" read only';

# create directory for datapump import


sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01''";
}
executing Memory Script
sql statement: alter tablespace

"CRMS" read only

sql statement: alter tablespace

"HRMS" read only

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01''


sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01''
Performing export of metadata...
EXPDP> Starting "SYS"."TSPITR_EXP_tjmt":
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX
EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

EXPDP> Master table "SYS"."TSPITR_EXP_tjmt" successfully loaded/unloaded


EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_tjmt is:
EXPDP>

/u01/tspitr_tjmt_40918.dmp

EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace CRMS:
EXPDP>

/u02/app/oracle/oradata/crms/crms01.dbf

EXPDP>

/u02/app/oracle/oradata/crms/crms02.dbf

EXPDP> Datafiles required for transportable tablespace HRMS:


EXPDP>

/u02/app/oracle/oradata/crms/hrms01.dbf

EXPDP>

/u02/app/oracle/oradata/crms/hrms02.dbf

EXPDP> Job "SYS"."TSPITR_EXP_tjmt" successfully completed at 12:41:02


Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone immediate
# drop target tablespaces before importing them back
sql 'drop tablespace

"HRMS" including contents keep datafiles';

}
executing Memory Script
database closed
database dismounted
Oracle instance shut down
sql statement: drop tablespace

"HRMS" including contents keep datafiles

Performing import of metadata...


IMPDP> Master table "SYS"."TSPITR_IMP_tjmt" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_tjmt":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX
IMPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYS"."TSPITR_IMP_tjmt" successfully completed at 12:41:22
Import completed

contents of Memory Script:


{
# make read write and offline the imported tablespaces
sql 'alter tablespace

"CRMS" read write';

sql 'alter tablespace

"CRMS" offline';

sql 'alter tablespace

"HRMS" read write';

sql 'alter tablespace

"HRMS" offline';

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

# enable autobackups after TSPITR is finished


sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script
sql statement: alter tablespace

"CRMS" read write

sql statement: alter tablespace

"CRMS" offline

sql statement: alter tablespace

"HRMS" read write

sql statement: alter tablespace

"HRMS" offline

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;


Removing automatic instance Automatic instance removed
auxiliary instance file /u01/CRMS/datafile/o1_mf_temp_bln6lq5l_.tmp deleted
auxiliary instance file /u01/CRMS/onlinelog/o1_mf_3_bln6lktx_.log deleted
auxiliary instance file /u01/CRMS/onlinelog/o1_mf_2_bln6lhd5_.log deleted
auxiliary instance file /u01/CRMS/onlinelog/o1_mf_1_bln6ldl9_.log deleted
auxiliary instance file /u01/CRMS/datafile/o1_mf_sysaux_bln6dpyh_.dbf deleted
auxiliary instance file /u01/CRMS/datafile/o1_mf_undotbs1_bln6dpwg_.dbf deleted
auxiliary instance file /u01/CRMS/datafile/o1_mf_system_bln6dpxl_.dbf deleted
auxiliary instance file /u01/CRMS/controlfile/o1_mf_bln6dhz6_.ctl deleted
Finished recover at 12-APR-15

CHECK THE TABLEPSACE STATUS AND EXISTANCE


SYS> select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME

STATUS

------------------------------ --------SYSTEM

ONLINE

SYSAUX

ONLINE

UNDOTBS1

ONLINE

TEMP

ONLINE

USERS

ONLINE

CRMS

OFFLINE

HRMS

OFFLINE

7 rows selected.
MAKE TABLESPACES TO ONLINE
SYS> alter tablespace crms online;
Tablespace altered.
SYS> alter tablespace hrms online;
Tablespace altered.
SYS> conn sony/sony
Connected.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

RMAN TABLESPACE POINT-IN-TIME RECOVERY - TSPITR

SONY> select * from tab;


TNAME

TABTYPE

CLUSTERID

------------------------------ ------- ---------TAB1

TABLE

TAB2

TABLE

TAB3

TABLE

SONY> select table_name, index_name, tablespace_name from user_indexes;


TABLE_NAME

INDEX_NAME

----------------

TABLESPACE_NAME

----------------- ------------------

TAB1

CONS1_PKEY

CRMS

TAB1

TAB1_GENDER_INDX1

HRMS

SONY> select * from tab4;


select * from tab4
*
ERROR at line 1:
ORA-00942: table or view does not exist
POINTS TO NOTE
Table TAB4 was not recovered because it was created under SYSTEM tablespace and TSPITR is NOT
supported for objects in system tablespace or objects are owned by SYS.
Index TAB3_GENDER_INDX1 is missing. Tablespace crms contains table TAB3 but indexes on that table
resides on another tablespace called USERS. In this case, if we perform TSPITR on crms tablespace
to some point-in-time, then we must recover USERS tablespace to the same point-in-time. But we
did not include users tablespace so index TAB3_GENDER_INDX1 was not recovered.

RMAN> list backup;


using target database control file instead of recovery catalog
List of Backup Sets
===================
..
...
List of Datafiles in backup set 490
File LV Type Ckp SCN

Ckp Time

Name

---- -- ---- ---------- --------- ---1

Full 3943214

12-APR-15 /u02/app/oracle/oradata/crms/system01.dbf

Full 3943214

12-APR-15 /u02/app/oracle/oradata/crms/sysaux01.dbf

Full 3943214

12-APR-15 /u02/app/oracle/oradata/crms/undotbs01.dbf

Full 3943214

12-APR-15 /u02/app/oracle/oradata/crms/users01.dbf

Full 3943214

12-APR-15

Full 3943214

12-APR-15

Full 3943214

12-APR-15

14

Full 3943214

12-APR-15

Once we performed TSPITR, you must re-take backup of the recovered tablespaces.

Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu

You might also like