Wednesday 7 August 2019

RMAN - Performing database point-in-time recovery (DBPITR) when the recovery point is known

Preview Senario:


  • Database in Archivelog mode
  • No catalog database
  • Table POM_BACKPOINTER drop
Solution :
  • Use Full backup database 
  • SHUTDOWN IMMEDIATE
  • STARTUP MOUNT
  • set session nls_date_format
  • SET UNTIL TIME restore point
  • DATABASE OPEN RESETLOGS
  • Check infodba.POM_BACKPOINTER table 
  • LIST INCARNATION OF DATABASE



[oracle@srv1 expdp]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Aug 7 14:01:04 2019

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

connected to target database: SMR1 (DBID=3409868754)

RMAN> BACKUP DATABASE TAG 'DB_FULL';

Starting backup at 07-AUG-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=70 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=00005 name=/u01/app/oracle/oradata/smr1/idata01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/smr1/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/smr1/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/smr1/undotbs01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/smr1/ilog01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/smr1/indx01.dbf
input datafile file number=00006 name=/u01/rmanbkp/copy_db_data_D-SMR1_I-3409868754_TS-USERS_FNO-6_0uu8k31s
channel ORA_DISK_1: starting piece 1 at 07-AUG-19
channel ORA_DISK_1: finished piece 1 at 07-AUG-19
piece handle=/u01/app/oracle/fast_recovery_area/SMR1/backupset/2019_08_07/o1_mf_nnndf_DB_FULL_gno32cco_.bkp tag=DB_FULL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting 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 07-AUG-19
channel ORA_DISK_1: finished piece 1 at 07-AUG-19
piece handle=/u01/app/oracle/fast_recovery_area/SMR1/backupset/2019_08_07/o1_mf_ncsnf_DB_FULL_gno35zo6_.bkp tag=DB_FULL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-AUG-19

RMAN> ALTER SYSTEM SWITCH LOGFILE;

Statement processed

RMAN> ALTER SYSTEM SWITCH LOGFILE;

Statement processed

RMAN>

SQL> select count(*) from infodba.POM_BACKPOINTER;

  COUNT(*)
----------
   3424222

SQL> SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD:HH24:MI:SS') FROM DUAL;

TO_CHAR(SYSDATE,'YY
-------------------
2019-08-07:14:15:22

SQL>

SQL> ALTER SYSTEM SWITCH LOGFILE;

System altered.

SQL> drop table infodba.POM_BACKPOINTER;

Table dropped.

[oracle@srv1 expdp]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Aug 7 14:16:45 2019

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

connected to target database: SMR1 (DBID=3409868754)

RMAN> SHUTDOWN IMMEDIATE;

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> STARTUP MOUNT;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    1795162112 bytes

Fixed Size                     2925456 bytes
Variable Size                553651312 bytes
Database Buffers            1224736768 bytes
Redo Buffers                  13848576 bytes


SQL>

RMAN> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Statement processed

RMAN> RUN
{
SET UNTIL TIME '2019-08-07:14:15:22';
RESTORE DATABASE;
RECOVER DATABASE;
}2> 3> 4> 5> 6>

executing command: SET until clause

Starting restore at 07-AUG-19
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/smr1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/smr1/ilog01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/smr1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/smr1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/smr1/idata01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/rmanbkp/copy_db_data_D-SMR1_I-3409868754_TS-USERS_FNO-6_0uu8k31s
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/smr1/indx01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/SMR1/backupset/2019_08_07/o1_mf_nnndf_DB_FULL_gno32cco_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/SMR1/backupset/2019_08_07/o1_mf_nnndf_DB_FULL_gno32cco_.bkp tag=DB_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:45
Finished restore at 07-AUG-19

Starting recover at 07-AUG-19
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 86 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_07/o1_mf_1_86_gno36b5n_.arc
archived log for thread 1 with sequence 87 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_07/o1_mf_1_87_gno36c7r_.arc
archived log for thread 1 with sequence 88 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_07/o1_mf_1_88_gno3xvxc_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_07/o1_mf_1_86_gno36b5n_.arc thread=1 sequence=86
media recovery complete, elapsed time: 00:00:01
Finished recover at 07-AUG-19

RMAN>
RMAN> ALTER DATABASE OPEN RESETLOGS;

Statement processed

RMAN>

RMAN> select count(*) from infodba.POM_BACKPOINTER;

  COUNT(*)
----------
   3424222

RMAN>

RMAN> LIST INCARNATION OF DATABASE;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       SMR1     3409868754       PARENT  1          07-JUL-14
2       2       SMR1     3409868754       PARENT  1594143    25-JUN-19
3       3       SMR1     3409868754       CURRENT 2329312    07-AUG-19

RMAN>

No comments:

Post a Comment