Tuesday, April 09, 2013

RMAN online recover tablespace

Objective: using incrementally updated backups to recvoery tablespace.


orarac2poc:TTS:/u02/oradata/TTS> rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Thu Apr 4 13:46:25 2013

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

connected to target database: TTS (DBID=1769654909)

RMAN>  backup incremental level 1 for recover of copy with tag daily_incr database;

Starting backup at 2013-04-04:13:46:36
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u02/oradata/TTS/system01.dbf
input datafile file number=00002 name=/u02/oradata/TTS/sysaux01.dbf
input datafile file number=00003 name=/u02/oradata/TTS/undotbs01.dbf
input datafile file number=00005 name=/u02/oradata/TTS/tts1_01.bdf
input datafile file number=00006 name=/u02/oradata/TTS/testtbs1.dbf
input datafile file number=00004 name=/u02/oradata/TTS/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2013-04-04:13:46:38
channel ORA_DISK_1: finished piece 1 at 2013-04-04:13:47:03
piece handle=/u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8ot4xyj6_.bkp tag=DAILY_INCR comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 2013-04-04:13:47:03

Starting Control File and SPFILE Autobackup at 2013-04-04:13:47:03
piece handle=/u02/oradata/TTS/FRA/TTS/autobackup/2013_04_04/o1_mf_s_811864023_8ot4yr7o_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2013-04-04:13:47:04

RMAN> backup as backupset archivelog all not backed up delete all input;

Starting backup at 2013-04-04:13:47:36
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=55 STAMP=811860423
channel ORA_DISK_1: starting piece 1 at 2013-04-04:13:47:36
channel ORA_DISK_1: finished piece 1 at 2013-04-04:13:47:37
piece handle=/u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_annnn_TAG20130404T134736_8ot4zrtf_.bkp tag=TAG20130404T134736 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u02/oradata/TTS/FRA/TTS/archivelog/2013_04_04/o1_mf_1_12_8ot1g77f_.arc RECID=55 STAMP=811860423
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=56 STAMP=811864056
channel ORA_DISK_1: starting piece 1 at 2013-04-04:13:47:38
channel ORA_DISK_1: finished piece 1 at 2013-04-04:13:47:39
piece handle=/u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_annnn_TAG20130404T134736_8ot4zt6m_.bkp tag=TAG20130404T134736 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u02/oradata/TTS/FRA/TTS/archivelog/2013_04_04/o1_mf_1_1_8ot4zr99_.arc RECID=56 STAMP=811864056
Finished backup at 2013-04-04:13:47:39

Starting Control File and SPFILE Autobackup at 2013-04-04:13:47:39
piece handle=/u02/oradata/TTS/FRA/TTS/autobackup/2013_04_04/o1_mf_s_811864059_8ot4zvj7_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2013-04-04:13:47:40

RMAN> recover device type disk copy of database with tag daily_incr;

Starting recover at 2013-04-04:13:47:52
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_system_8oqzctbg_.dbf
recovering datafile copy file number=00002 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_sysaux_8oqzdxo7_.dbf
recovering datafile copy file number=00003 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_undotbs1_8oqzg18b_.dbf
recovering datafile copy file number=00004 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_users_8oqzgm55_.dbf
recovering datafile copy file number=00005 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_tts1_8oqzgjgw_.dbf
recovering datafile copy file number=00006 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_testtbs_8oqzgks6_.dbf
channel ORA_DISK_1: reading from backup piece /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8oswzlpr_.bkp
channel ORA_DISK_1: piece handle=/u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8oswzlpr_.bkp tag=DAILY_INCR
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_system_8oqzctbg_.dbf
recovering datafile copy file number=00002 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_sysaux_8oqzdxo7_.dbf
recovering datafile copy file number=00003 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_undotbs1_8oqzg18b_.dbf
recovering datafile copy file number=00004 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_users_8oqzgm55_.dbf
recovering datafile copy file number=00005 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_tts1_8oqzgjgw_.dbf
recovering datafile copy file number=00006 name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_testtbs_8oqzgks6_.dbf
channel ORA_DISK_1: reading from backup piece /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8ot4xyj6_.bkp
channel ORA_DISK_1: piece handle=/u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8ot4xyj6_.bkp tag=DAILY_INCR
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2013-04-04:13:47:55

Starting Control File and SPFILE Autobackup at 2013-04-04:13:47:56
piece handle=/u02/oradata/TTS/FRA/TTS/autobackup/2013_04_04/o1_mf_s_811864076_8ot50d6j_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2013-04-04:13:47:57

RMAN> host 'ls -l /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8oswzlpr_.bkp';

-rw-r----- 1 oracle asmadmin 106496 Apr  4 11:31 /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8oswzlpr_.bkp
host command complete

RMAN> host 'ls -l /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8ot4xyj6_.bkp';

-rw-r----- 1 oracle asmadmin 1515520 Apr  4 13:46 /u02/oradata/TTS/FRA/TTS/backupset/2013_04_04/o1_mf_nnnd1_DAILY_INCR_8ot4xyj6_.bkp
host command complete

RMAN> exit


Recovery Manager complete.

 Test tablespace level recovery.

orarac2poc:TTS:/u02/oradata/TTS> sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Apr 4 13:54:25 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options


SYS@TTS> alter tablespace tts1 offline immediate;

Tablespace altered.

SYS@TTS> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
orarac2poc:TTS:/u02/oradata/TTS> ls -l
total 2144832
drwxr-xr-x 2 oracle oinstall      4096 Apr  2 16:57 bak
-rw-r----- 1 oracle oinstall  10010624 Apr  4 13:54 control01.ctl
-rw-r----- 1 oracle oinstall  10010624 Apr  4 11:35 control01.ctl.bak
-rw-r----- 1 oracle oinstall     46773 Apr  4 11:35 control01.ctl.gz
-rw-r----- 1 oracle oinstall  10010624 Apr  4 13:54 control02.ctl
-rw-r----- 1 oracle oinstall     46773 Apr  4 11:35 control02.ctl.gz
drwxr-xr-x 3 oracle oinstall      4096 Mar 27 09:33 FRA
drwxr-xr-x 2 oracle oinstall      4096 Apr  4 12:03 redo
-rw-r----- 1 oracle oinstall  52429312 Apr  4 13:47 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Apr  4 13:54 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Apr  4 12:47 redo03.log
-rw-r----- 1 oracle asmadmin 629153792 Apr  4 13:53 sysaux01.dbf
-rw-r----- 1 oracle oinstall  76678173 Apr  4 11:34 sysaux01.dbf.gz
-rw-r----- 1 oracle asmadmin 734011392 Apr  4 13:52 system01.dbf
-rw-r----- 1 oracle oinstall 127967092 Apr  4 11:34 system01.dbf.gz
-rw-r----- 1 oracle asmadmin  20979712 Apr  4 12:47 temp01.dbf
-rw-r----- 1 oracle oinstall   6117241 Apr  4 00:54 temp01.dbf.gz
-rw-r----- 1 oracle asmadmin  10493952 Apr  4 13:47 testtbs1.dbf
-rw-r----- 1 oracle oinstall     24376 Apr  4 11:34 testtbs1.dbf.gz
-rw-r----- 1 oracle asmadmin  20979712 Apr  4 13:47 tts1_01.bdf
-rw-r----- 1 oracle oinstall   1137516 Apr  4 11:34 tts1_01.bdf.gz
-rw-r----- 1 oracle asmadmin 387981312 Apr  4 13:53 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5753888 Apr  4 11:34 undotbs01.dbf.gz
-rw-r----- 1 oracle asmadmin   5251072 Apr  4 13:47 users01.dbf
-rw-r----- 1 oracle oinstall     13674 Apr  4 11:34 users01.dbf.gz
orarac2poc:TTS:/u02/oradata/TTS> mv tts1_01.bdf tts1_01.bdf.bak
orarac2poc:TTS:/u02/oradata/TTS> rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Thu Apr 4 13:55:01 2013

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

connected to target database: TTS (DBID=1769654909)

RMAN> restore tablespace tts1;

Starting restore at 2013-04-04:13:55:11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK

channel ORA_DISK_1: restoring datafile 00005
input datafile copy RECID=87 STAMP=811864075 file name=/u02/oradata/TTS/FRA/TTS/datafile/o1_mf_tts1_8oqzgjgw_.dbf
destination for restore of datafile 00005: /u02/oradata/TTS/tts1_01.bdf
channel ORA_DISK_1: copied datafile copy of datafile 00005
output file name=/u02/oradata/TTS/tts1_01.bdf RECID=0 STAMP=0
Finished restore at 2013-04-04:13:55:14

RMAN> recover tablespace tts1;

Starting recover at 2013-04-04:13:55:21
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:02

Finished recover at 2013-04-04:13:55:23

RMAN> sql 'alter tablespace tts1 online';

sql statement: alter tablespace tts1 online

RMAN> exit


Recovery Manager complete.
orarac2poc:TTS:/u02/oradata/TTS> ls -lrt
total 2165344
drwxr-xr-x 3 oracle oinstall      4096 Mar 27 09:33 FRA
drwxr-xr-x 2 oracle oinstall      4096 Apr  2 16:57 bak
-rw-r----- 1 oracle oinstall   6117241 Apr  4 00:54 temp01.dbf.gz
-rw-r----- 1 oracle oinstall     13674 Apr  4 11:34 users01.dbf.gz
-rw-r----- 1 oracle oinstall   5753888 Apr  4 11:34 undotbs01.dbf.gz
-rw-r----- 1 oracle oinstall   1137516 Apr  4 11:34 tts1_01.bdf.gz
-rw-r----- 1 oracle oinstall     24376 Apr  4 11:34 testtbs1.dbf.gz
-rw-r----- 1 oracle oinstall 127967092 Apr  4 11:34 system01.dbf.gz
-rw-r----- 1 oracle oinstall  76678173 Apr  4 11:34 sysaux01.dbf.gz
-rw-r----- 1 oracle oinstall     46773 Apr  4 11:35 control02.ctl.gz
-rw-r----- 1 oracle oinstall     46773 Apr  4 11:35 control01.ctl.gz
-rw-r----- 1 oracle oinstall  10010624 Apr  4 11:35 control01.ctl.bak
drwxr-xr-x 2 oracle oinstall      4096 Apr  4 12:03 redo
-rw-r----- 1 oracle oinstall  52429312 Apr  4 12:47 redo03.log
-rw-r----- 1 oracle asmadmin  20979712 Apr  4 12:47 temp01.dbf
-rw-r----- 1 oracle asmadmin   5251072 Apr  4 13:47 users01.dbf
-rw-r----- 1 oracle asmadmin  20979712 Apr  4 13:47 tts1_01.bdf.bak
-rw-r----- 1 oracle asmadmin  10493952 Apr  4 13:47 testtbs1.dbf
-rw-r----- 1 oracle oinstall  52429312 Apr  4 13:47 redo01.log
-rw-r----- 1 oracle asmadmin 387981312 Apr  4 13:53 undotbs01.dbf
-rw-r----- 1 oracle asmadmin 629153792 Apr  4 13:53 sysaux01.dbf
-rw-r----- 1 oracle asmadmin  20979712 Apr  4 13:55 tts1_01.bdf
-rw-r----- 1 oracle asmadmin 734011392 Apr  4 13:55 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Apr  4 13:55 redo02.log
-rw-r----- 1 oracle oinstall  10010624 Apr  4 13:55 control02.ctl
-rw-r----- 1 oracle oinstall  10010624 Apr  4 13:55 control01.ctl
orarac2poc:TTS:/u02/oradata/TTS> ls -lrt tts*
-rw-r----- 1 oracle oinstall  1137516 Apr  4 11:34 tts1_01.bdf.gz
-rw-r----- 1 oracle asmadmin 20979712 Apr  4 13:47 tts1_01.bdf.bak
-rw-r----- 1 oracle asmadmin 20979712 Apr  4 13:55 tts1_01.bdf