Introduction of RMAN (Recovery Manager)

* Rman is nothing  but Recovery Manager . it's an automated tool of oracle backup and recovery

* It has some features which have made dba job very easily * Rman Was introduced in  oracle 8i version but it has not robust as it today which means each version it has been improvised

* Oracle recommends for Rman backup and recovery * Rman is faster it takes the backup of block level

* Parallelism - We can initiate parallel processes * Detecting  corruption in data files - Rman will detect the block corruption and repair it

* Validating Backup - Rman will cross check  the backup  whether the backup is   active ,Obsolete backup  and expired backup

* Recovery Catalog - Rman stores backup metadata information in the database control file , we can also  store that information into different database control file on different server

* Incremental Backup - Level 0 Full database Backup - Level 1 Backup of changed blocks after the full backup  by referring data block header for updated scn

* Archive log is must be used  in Rman

* Multi-Destination backup - Simultaneously we can store the  backup in multiple places

Components of Rman :

* Rman Prompt - The target database command line  when we used to  starts the Rman

* Target Database - The Target Database is nothing but the database is which connects Rman with  sysdba privilege

* Auxilary Database - Clone of target database or standby

* Recovery Catalog - (Already explained in above)

* Media Management Layers - Media Management Layers  is  the layer which is in between of database and third-party backup software or tools

* Rman Channels - Channel is device type (i.e disk or tape)

Full Backup

- Entire database will be backup - We cannot  perform Incremental backup command

- After taking backup if any changes happen it would not be recoverable

i)Only database full backup

RMAN> Backup database;

ii)taking database backup along with archive log

RMAN>backup database plus archivelog;

Note: if we don't configure backup location in rman parameter by default it ll take on fast recovery area

Incremental Backup

- Full Database  Backup    

- Backup  changes only from last level 0 database backup

- It takes the database backup only used  blocks not free blocks

- The database can be restored until  it was crashed

Level 0 Database backup

RMAN> Backup incremental level 0 database

 Level 1 database Backup

RMAN> Backup incremental level 1 database

To View Backup in database 

I)list backup - it displays listed of backup sets in database
RMAN> list backup;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
2       58.93M     DISK        00:00:35     09-JUN-16     
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20160609T064309
        Piece Name: /u01/app/oracle/product/11.2.0.3/flash_recovery_area/CA/backupset/2016_06_09/o1_mf_annnn_TAG20160609T064309_cokjofm7_.bkp

  List of Archived Logs in backup set 2
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    1       1084868    10-MAY-16 1117215    02-JUN-16
  1    2       1117215    02-JUN-16 1144809    09-JUN-16
  1    3       1144809    09-JUN-16 1145565    09-JUN-16
  1    4       1145565    09-JUN-16 1146187    09-JUN-16
  1    5       1146187    09-JUN-16 1146540    09-JUN-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    971.87M    DISK        00:03:18     09-JUN-16     
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20160609T064353
        Piece Name: /u01/app/oracle/product/11.2.0.3/flash_recovery_area/CA/backupset/2016_06_09/o1_mf_nnndf_TAG20160609T064353_cokjpq0k_.bkp
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1146556    09-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/system01.dbf
  2       Full 1146556    09-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/sysaux01.dbf
  3       Full 1146556    09-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/undotbs01.dbf
  4       Full 1146556    09-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/users01.dbf
  5       Full 1124206    02-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/neuk.dbf
  6       Full 1124206    02-JUN-16 /u01/app/oracle/product/11.2.0.3/oradata/CA/neuk01.dbf

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4       159.50K    DISK        00:00:01     09-JUN-16     
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20160609T064721
        Piece Name: /u01/app/oracle/product/11.2.0.3/flash_recovery_area/CA/backupset/2016_06_09/o1_mf_annnn_TAG20160609T064721_cokjx1gp_.bkp

  List of Archived Logs in backup set 4
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    6       1146540    09-JUN-16 1146701    09-JUN-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5       Full    9.36M      DISK        00:00:04     09-JUN-16     
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20160609T064726
        Piece Name: /u01/app/oracle/product/11.2.0.3/flash_recovery_area/CA/autobackup/2016_06_09/o1_mf_s_914050046_cokjx9hl_.bkp
  SPFILE Included: Modification time: 09-JUN-16
  SPFILE db_unique_name: CA
  Control File Included: Ckp SCN: 1146710      Ckp time: 09-JUN-16



II)List backup summary - summary of backup sets

RMAN> list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
2       B  A  A DISK        09-JUN-16       1       1       NO         TAG20160609T064309
3       B  F  A DISK        09-JUN-16       1       1       NO         TAG20160609T064353
4       B  A  A DISK        09-JUN-16       1       1       NO         TAG20160609T064721
5       B  F  A DISK        09-JUN-16       1       1       NO         TAG20160609T064726

III)List backup of database summary - details of backup levels

RMAN> list backup of database summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
3       B  F  A DISK        09-JUN-16       1       1       NO         TAG20160609T064353

Note : Here 4th  column "S" status of the backup "A"-Active,"X"-Expired

why restore a database always preferable of an  incremental backup?

* our database has suddenly crashed we took a database full backup last three days before we restore our database when the database is taken the backup which means the data has been the loss of those three days from we took the full backup.

*in-case if we took incremental backup we can restore our database till that time its was crashed no data loss has occurred.

To recover a database from incremental backup

*As per recovery, we must only restore the database from level 0 and recovery database using level 1 when we try to take level 1 backup ,Rman is an intelligent tool it first checks whether the database has level 0 backup  already .

if not it will take level 0 backup recovery is of two parts

I) restore

II) recovery

we cannot recover the database without doing  the restore

Note: restore and Recovery will be in details on another topic

list backup - it displays listed of backup sets in a database