How to restore and recover a differential incremental Oracle database backup
Scenario: We have Level 0 backup on Tuesday, Level 1 Differential backup on Wednesday & Thursday and Level 1 Cumulative on Friday. On the very next day Saturday, due to media failure database has been crashed, in this case how to recover from above mentioned RMAN backups.
Here is practical approach to recover database.
login as: oracle
oracle@192.168.173.2's password:
Last login: Fri Jan 26 19:55:42 2018 from 192.168.173.1
[oracle@dba1 ~]$
[oracle@dba1 ~]$
[oracle@dba1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 29 18:36:44 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1703624704 bytes
Fixed Size 2229024 bytes
Variable Size 452988128 bytes
Database Buffers 1241513984 bytes
Redo Buffers 6893568 bytes
Database mounted.
Database opened.
SQL> set time on
18:37:24 SQL>
18:37:24 SQL>
18:37:24 SQL>
18:37:29 SQL>
18:37:30 SQL> disc
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
18:37:33 SQL>
18:37:33 SQL> conn venky/venky
Connected.
18:37:37 SQL>
18:37:39 SQL>
18:37:39 SQL>
18:37:43 SQL>
18:37:43 SQL> sho user
USER is "VENKY"
18:37:45 SQL>
18:37:45 SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
DUMMY TABLE
EMP TABLE
SALGRADE TABLE
18:37:51 SQL> select count(1) from bonus;
COUNT(1)
----------
3584
18:37:59 SQL> select count(1) from dept;
COUNT(1)
----------
4
18:38:08 SQL> select count(1) from DUMMY
18:38:20 2 ;
COUNT(1)
----------
1
18:38:21 SQL> select count(1) from emp;
COUNT(1)
----------
14
18:38:27 SQL> select count(1) from SALGRADE;
COUNT(1)
----------
5
18:38:37 SQL>
18:39:05 SQL>
18:39:05 SQL> disc
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
18:39:10 SQL>
18:39:11 SQL> conn / as sysdba
Connected.
18:39:17 SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
18:39:21 SQL>
18:39:22 SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
18:39:38 SQL> disc
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
18:40:12 SQL> exit
[oracle@dba1 ~]$
[oracle@dba1 ~]$
[oracle@dba1 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 8.8G 6.0G 2.3G 73% /
/dev/sda7 4.9G 153M 4.5G 4% /tmp
/dev/sda5 8.7G 7.0G 1.3G 86% /home
/dev/sda2 13G 6.9G 5.3G 57% /u01
/dev/sda1 4.9G 178M 4.5G 4% /boot
tmpfs 2.7G 0 2.7G 0% /dev/shm
[oracle@dba1 ~]$
[oracle@dba1 ~]$ cd /u01
[oracle@dba1 u01]$ ll
total 28
drwxrwxr-x 4 oracle oinstall 4096 Nov 11 22:52 app
drwxr-xr-x 3 oracle oinstall 4096 Nov 12 15:48 app1
drwxrwxr-x 2 oracle oinstall 16384 Nov 11 09:33 lost+found
drwxr-xr-x 5 oracle oinstall 4096 Jan 23 20:55 prd
[oracle@dba1 u01]$ cd prd/
[oracle@dba1 prd]$ ll
total 12
drwxr-xr-x 3 oracle oinstall 4096 Nov 12 14:45 datafiles
drwxr-xr-x 2 oracle oinstall 4096 Jan 23 21:02 db_create
drwxr-xr-x 2 oracle oinstall 4096 Jan 26 20:00 rman
[oracle@dba1 prd]$ cd datafiles/
[oracle@dba1 datafiles]$ ll
total 4
drwxr-x--- 2 oracle oinstall 4096 Nov 12 14:48 prd
[oracle@dba1 datafiles]$ cd prd/
[oracle@dba1 prd]$ ll
total 1461088
-rw-r----- 1 oracle oinstall 9748480 Jan 29 18:39 control01.ctl
-rw-r----- 1 oracle oinstall 52429312 Jan 29 18:39 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 29 18:37 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 29 18:37 redo03.log
-rw-r----- 1 oracle oinstall 545267712 Jan 29 18:39 sysaux01.dbf
-rw-r----- 1 oracle oinstall 744497152 Jan 29 18:39 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Jan 29 18:37 temp01.dbf
-rw-r----- 1 oracle oinstall 31465472 Jan 29 18:39 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Jan 29 18:39 users01.dbf
[oracle@dba1 prd]$ rm * (manually I have deleted all the datafiles)
[oracle@dba1 prd]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 29 18:44:33 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1703624704 bytes
Fixed Size 2229024 bytes
Variable Size 452988128 bytes
Database Buffers 1241513984 bytes
Redo Buffers 6893568 bytes
ORA-00205: error in identifying control file, check alert log for more info
SQL> shut abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dba1 prd]$
[oracle@dba1 prd]$ cd /u01/prd/rman/
[oracle@dba1 rman]$ ll
total 1075824
-rw-r----- 1 oracle oinstall 1046519808 Jan 23 21:06 230118_level0.bkp
-rw-r----- 1 oracle oinstall 4153344 Jan 24 21:33 240118_levle0_diff.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 24 21:39 cf_wed.ctl
-rw-r----- 1 oracle oinstall 11927552 Jan 26 19:59 fridy_cum.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 26 20:00 fridy_cum_CF.ctl
-rw-r----- 1 oracle oinstall 9797632 Jan 25 20:31 thurs_cf.ctl
-rw-r----- 1 oracle oinstall 8536064 Jan 25 20:31 thurs_levl0.bkp
[oracle@dba1 rman]$ ls -ltr
total 1075824
-rw-r----- 1 oracle oinstall 1046519808 Jan 23 21:06 230118_level0.bkp
-rw-r----- 1 oracle oinstall 4153344 Jan 24 21:33 240118_levle0_diff.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 24 21:39 cf_wed.ctl
-rw-r----- 1 oracle oinstall 8536064 Jan 25 20:31 thurs_levl0.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 25 20:31 thurs_cf.ctl
-rw-r----- 1 oracle oinstall 11927552 Jan 26 19:59 fridy_cum.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 26 20:00 fridy_cum_CF.ctl
[oracle@dba1 rman]$
[oracle@dba1 rman]$
[oracle@dba1 rman]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Jan 29 18:45:16 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN>
RMAN> startup nomount;
Oracle instance started
Total System Global Area 1703624704 bytes
Fixed Size 2229024 bytes
Variable Size 452988128 bytes
Database Buffers 1241513984 bytes
Redo Buffers 6893568 bytes
RMAN>
RMAN> restore controlfile from '/u01/prd/rman/fridy_cum_CF.ctl';
Starting restore at 29-JAN-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/prd/datafiles/prd/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/prd/control02.ctl
Finished restore at 29-JAN-18
RMAN> exit
(In latest available controlfile, it contains all the backup information. So we have restore latest controlfile and lets bring the database in mount mode)
Recovery Manager complete.
[oracle@dba1 rman]$ ls -ltr
total 1075824
-rw-r----- 1 oracle oinstall 1046519808 Jan 23 21:06 230118_level0.bkp
-rw-r----- 1 oracle oinstall 4153344 Jan 24 21:33 240118_levle0_diff.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 24 21:39 cf_wed.ctl
-rw-r----- 1 oracle oinstall 8536064 Jan 25 20:31 thurs_levl0.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 25 20:31 thurs_cf.ctl
-rw-r----- 1 oracle oinstall 11927552 Jan 26 19:59 fridy_cum.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 26 20:00 fridy_cum_CF.ctl
[oracle@dba1 rman]$ cd ../
[oracle@dba1 prd]$ ll
total 12
drwxr-xr-x 3 oracle oinstall 4096 Nov 12 14:45 datafiles
drwxr-xr-x 2 oracle oinstall 4096 Jan 23 21:02 db_create
drwxr-xr-x 2 oracle oinstall 4096 Jan 26 20:00 rman
[oracle@dba1 prd]$ cd datafiles/prd/
[oracle@dba1 prd]$ ll
total 9536
-rw-r----- 1 oracle oinstall 9748480 Jan 29 18:52 control01.ctl
[oracle@dba1 prd]$ pwd
/u01/prd/datafiles/prd
[oracle@dba1 prd]$
[oracle@dba1 prd]$
[oracle@dba1 prd]$ cd /u01/prd/rman/
[oracle@dba1 rman]$ ll
total 1075824
-rw-r----- 1 oracle oinstall 1046519808 Jan 23 21:06 230118_level0.bkp
-rw-r----- 1 oracle oinstall 4153344 Jan 24 21:33 240118_levle0_diff.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 24 21:39 cf_wed.ctl
-rw-r----- 1 oracle oinstall 11927552 Jan 26 19:59 fridy_cum.bkp
-rw-r----- 1 oracle oinstall 9797632 Jan 26 20:00 fridy_cum_CF.ctl
-rw-r----- 1 oracle oinstall 9797632 Jan 25 20:31 thurs_cf.ctl
-rw-r----- 1 oracle oinstall 8536064 Jan 25 20:31 thurs_levl0.bkp
[oracle@dba1 rman]$
[oracle@dba1 rman]$
[oracle@dba1 rman]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Jan 29 18:56:18 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRD (not mounted)
RMAN> alter database mount;
using target database control file instead of recovery catalog
database mounted
RMAN> list backup summary ;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
2 B F A DISK 23-JAN-18 1 1 NO TAG20180123T205322
3 B 0 A DISK 23-JAN-18 1 1 NO TUESDAY_LEVEL0
4 B F A DISK 23-JAN-18 1 1 NO TAG20180123T210739
5 B 1 A DISK 24-JAN-18 1 1 NO WED_LEVEL1_DIF
6 B F A DISK 24-JAN-18 1 1 NO TAG20180124T213340
7 B F A DISK 24-JAN-18 1 1 NO TAG20180124T213931
8 B F A DISK 24-JAN-18 1 1 NO TAG20180124T213933
9 B 1 A DISK 25-JAN-18 1 1 NO THURSDAY_LEVEL0
10 B F A DISK 25-JAN-18 1 1 NO TAG20180125T203119
11 B F A DISK 25-JAN-18 1 1 NO TAG20180125T203150
12 B F A DISK 25-JAN-18 1 1 NO TAG20180125T203152
13 B 1 A DISK 26-JAN-18 1 1 NO FRIDAY_LEVEL1_CUM
14 B F A DISK 26-JAN-18 1 1 NO TAG20180126T195932
RMAN> restore database;
Starting restore at 29-JAN-18
Starting implicit crosscheck backup at 29-JAN-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
Crosschecked 13 objects
Finished implicit crosscheck backup at 29-JAN-18
Starting implicit crosscheck copy at 29-JAN-18
using channel ORA_DISK_1
Finished implicit crosscheck copy at 29-JAN-18
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PRD/autobackup/2018_01_26/o1_mf_s_966456025_f6pgw14b_.bkp
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/prd/datafiles/prd/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/prd/datafiles/prd/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/prd/datafiles/prd/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/prd/datafiles/prd/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/prd/rman/230118_level0.bkp
channel ORA_DISK_1: piece handle=/u01/prd/rman/230118_level0.bkp tag=TUESDAY_LEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:45
Finished restore at 29-JAN-18
RMAN> recover database;
Starting recover at 29-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/prd/datafiles/prd/system01.dbf
destination for restore of datafile 00002: /u01/prd/datafiles/prd/sysaux01.dbf
destination for restore of datafile 00003: /u01/prd/datafiles/prd/undotbs01.dbf
destination for restore of datafile 00004: /u01/prd/datafiles/prd/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/prd/rman/fridy_cum.bkp
channel ORA_DISK_1: piece handle=/u01/prd/rman/fridy_cum.bkp tag=FRIDAY_LEVEL1_CUM
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
starting media recovery
unable to find archived log
archived log thread=1 sequence=4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/29/2018 19:01:24
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 4 and starting SCN of 1037192
RMAN> alter database open resetlogs;
database opened
RMAN> quit
Recovery Manager complete.
[oracle@dba1 rman]$
[oracle@dba1 rman]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 29 19:03:29 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$database;
NAME
---------
PRD
SQL>
SQL>
SQL>
SQL> disc
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> conn venky
Enter password:
Connected.
SQL>
SQL>
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
DUMMY TABLE
EMP TABLE
SALGRADE TABLE
SQL> select count(1) from bonus;
COUNT(1)
----------
3584
SQL> select count(1) from dept;
COUNT(1)
----------
4
SQL> select count(1) from dummy;
COUNT(1)
----------
1
SQL> select count(1) from emp;
COUNT(1)
----------
14
SQL> select count(1) from SALGRADE;
COUNT(1)
----------
5
SQL>
SQL> disc
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> conn / as sysdba
Connected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL>
SQL> !
[oracle@dba1 rman]$
[oracle@dba1 rman]$ cd ../
[oracle@dba1 prd]$ l
bash: l: command not found
[oracle@dba1 prd]$ ll
total 12
drwxr-xr-x 3 oracle oinstall 4096 Nov 12 14:45 datafiles
drwxr-xr-x 3 oracle oinstall 4096 Jan 29 19:02 db_create
drwxr-xr-x 2 oracle oinstall 4096 Jan 26 20:00 rman
[oracle@dba1 prd]$ cd datafiles/
[oracle@dba1 datafiles]$
[oracle@dba1 datafiles]$ ll
total 4
drwxr-x--- 2 oracle oinstall 4096 Jan 29 19:03 prd
[oracle@dba1 datafiles]$ cd prd/
[oracle@dba1 prd]$ ll
total 1461080
-rw-r----- 1 oracle oinstall 9748480 Jan 29 19:07 control01.ctl
-rw-r----- 1 oracle oinstall 52429312 Jan 29 19:05 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 29 19:03 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 29 19:03 redo03.log
-rw-r----- 1 oracle oinstall 545267712 Jan 29 19:03 sysaux01.dbf
-rw-r----- 1 oracle oinstall 744497152 Jan 29 19:03 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Jan 29 19:03 temp01.dbf
-rw-r----- 1 oracle oinstall 31465472 Jan 29 19:03 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Jan 29 19:03 users01.dbf
[oracle@dba1 prd]$ pwd
/u01/prd/datafiles/prd
[oracle@dba1 prd]$
[oracle@dba1 prd]$
No comments:
Post a Comment