RMAN Recovery scenarios



1-  If you lost all data files
SQL> startup mount;
RMAN> restore database;
RMAN> recover database;
SQL> alter database open;
2- If you lost a tablespace;
SQL> alter tablespace krish offline;
RMAN> restore tablespace krish;
RMAN> recover tablespace krish;
SQL> alter tablespace krish online;
if you can not offline tablespace;
$ sqlplus “/ as sysdba”
SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb
RMAN> restore tablespace krish;
RMAN> recover tablespace krish;
SQL> alter database open;
3- if you lost a datafile;
SQL> alter database datafile '/oracle/oradata/users.dbf' offline;
RMAN> restore datafile '/oracle/oradata/krish.dbf'
RMAN> recover datafile '/oracle/oradata/krish.dbf'
SQL> alter database datafile '/oracle/oradata/krish.dbf' online;
if you cannot offline datafile;                                                                   
$ sqlplus “/ as sysdba”
SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb
RMAN> restore datafile '/oracle/oradata/krish.dbf';
RMAN> recover datafile '/oracle/oradata/krish.dbf';
SQL> alter database open;
4-  if you lost your controlfiles;
$ sqlplus “/ as sysdba”
SQL> shutdown abort;
SQL> startup nomount;
$ rman target / catalog_user/password@catdb
RMAN> set dbid = 24054014;
RMAN> restore controlfile;
SQL> alter database mount;
SQL> alter database open;
you will receive an error ORA-01589 when you open database
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb RMAN>
recover database;
SQL> alter database open resetlogs;
RMAN> reset database;
if you open database with resetlogs, SCN number will be zero. In this situation
all previous backups will be invalid. You must full backup.



5-You need to incomplete recovery
A. Time-Based incomplete recovery;
$ sqlplus "/ as sysdba"
SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb
RMAN> restore database until time "to_date('05/05/13 12:0:00','DD/MM/YY HH24:MI:SS')";
RMAN> recover database until time "to_date('05/05/11 12:0:00','DD/MM/YY HH24:MI:SS')";
SQL> alter database open resetlogs;
B. SCN-Based incomplete recovery;
$ sqlplus "/ as sysdba"
SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb
RMAN> restore database until scn 154215;
RMAN> recover database until scn 154215;
SQL> alter database open resetlogs;
C. Archive log sequence based incomplete recovery;
$ sqlplus "/ as sysdba"
SQL> shutdown abort;
SQL> startup mount;
$ rman target / catalog_user/password@catdb
RMAN> restore database until sequence 10245;
RMAN> recover database until sequence 10245;
SQL> alter database open resetlogs;
6-  if you need some archive logs in your backup
$ rman target / catalog_user/password@catdb
RMAN> restore ARCHIVELOG FROM TIME 'SYSDATE-1' UNTIL TIME 'SYSDATE';
OR
RMAN> restore ARCHIVELOG FROM TIME "to_date('03/10/13 00:00:01','MM/DD/YY HH24:MI:SS') UNTIL TIME 'SYSDATE';
7- if your data block is corrupted you will receive an error below.
Error:
ORA-01578: ORACLE data block corrupted (file # 8, block # 13)
ORA-01110: data file 8: ‘/oracle/oradata/users.dbf’
for recover data block;
$ rman target / catalog_user/password@catdb
RMAN>blockrecover datafile 8 block 13;
For Block-Level Media Recovery – Concept & Example (Doc ID 144911.1)
To recover, we can give a specific backup set;
# recovery from backupset
RMAN> BLOCKRECOVER DATAFILE 8 BLOCK 13 DATAFILE 4 BLOCK 19 FROM BACKUPSET;
# recovery from image copy
RMAN> BLOCKRECOVER DATAFILE 8 BLOCK 13 DATAFILE 4 BLOCK 19
      FROM DATAFILECOPY;
# recovery from backupset which have "krish" tag
RMAN> BLOCKRECOVER DATAFILE 8 BLOCK 13 DATAFILE 4 BLOCK 19
       FROM TAG = krish;



Using Validate Backup command RMAN finds corrupted blocks and writes to V$DATABASE_BLOCK_CORRUPTION view. When the RMAN recover the corrupt block then automatically updates this view. List of all the corruption of the past, can be viewed over V$BACKUP_CORRUPTION and V$COPY_CORRUPTION views.  If you run the following command,  RMAN will recover all the corrupted blocks in view V$DATABASE_BLOCK_CORRUPTION.
RMAN>BLOCKRECOVER CORRUPTION LIST
  RESTORE UNTIL TIME 'SYSDATE-10';
8- if you have a image copy backup and your datafile number 4 has problems then you
can switch datafile number4 to image copy.
RMAN>sql ‘alter database datafile 4 offline’;
RMAN>switch datafile 4 to copy;
RMAN>recover datafile 4;
RMAN>sql ‘alter database datafile 4 online’;



Script for UDAY

run
{
allocate channel ch1 device type DISK;
allocate channel ch2 device type DISK;
allocate channel ch3 device type DISK;
allocate channel ch4 device type DISK;
allocate channel ch5 device type DISK;
allocate channel ch6 device type DISK;
crosscheck archivelog all;
backup incremental level 0 format '/exports/sentry/prod/rman/%d_%T_%t_%s_%p_L0.bkp' database ;
sql 'ALTER system switch logfile';
backup current controlfile format '/exports/sentry/prod/rman/%d_%T_%t_%s_%p.ctl';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;

}


No comments:

Post a Comment

Thank for showing interest in giving comments/feedback/suggestions

Note: Only a member of this blog may post a comment.