Skip to content

Latest commit

 

History

History
119 lines (114 loc) · 3 KB

rman_backup_recovery.md

File metadata and controls

119 lines (114 loc) · 3 KB

RMAN

Recovery Manager (RMAN) is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies backing up, restoring, and recovering database files.

Backup and Recovery using RMAN

Connect to RMAN

  1. Using rman keyword followed by connect target keyword
% rman
RMAN> CONNECT TARGET SYS@prod

target database Password: password
connected to target database: PROD (DBID=39525561)

Other option of logging is using os authentication.

% rman
RMAN> CONNECT TARGET /

connected to target database: PROD (DBID=39525561)

To quit RMAN, enter EXIT keyword

RMAN> EXIT
  1. View the current RMAN configuration for a database: Connect to RMAN and run show all
RMAN> SHOW ALL;
  1. Configure RMAN backup location
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backup/rman/full_%u_%s_%p';
  1. Configure retention period
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
  1. To clear any RMAN parameter use CLEAR command. Clear command reset the parameter back to default.
RMAN> CONFIGURE RETENTION POLICY CLEAR;
  1. Backup the database
    • Backup without archive logs
    RMAN> BACKUP AS BACKUPSET DATABASE
    • Backup with archive logs
    RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;
    • Backup specific tablespace
    RMAN> BACKUP AS BACKUPSET TABLESPACE PRD01;
    • For easy identification, backup can be tagged also
    BACKUP AS BACKUPSET TAG 'WEEEKLY_PRD01_TBLS_BK_ONLY' TABLESPACE PRD01;
  2. Verify backup in file system
$ls -l /backup/rman
  1. View all RMAN backups
RMAN> LIST BACKUP SUMMARY;

RMAN recovery

  1. Restore controlfile from backup
RMAN> STARTUP NOMOUNT;
RMAN> RESTORE CONTROLFILE FROM "/backup/rman/ctl_c-12345-20191212-03";
RMAN> ALTER DATABASE MOUNT;
  1. Restore controlfile based on tag
RMNAN> RESTORE CONTROLFILE FROM TAG 'WEEKLY_FULL_BKUP';
  1. Restore controlfile from autobackup
RMNAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
  1. Restore the database
RMAN> RESTORE DATABASE;
  1. In case controlfiles are restored from backup then use below command
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN RESETLOGS;
  1. Restore specific tablespace
RMNAN> RESTORE TABLESPACE dev1;
RMNAN> RESTORE TABLESPACE dev1, dev2; # restoring multiple tablespaces
  1. Restore specific datafiles
RMNAN> RESTORE DATAFILE '/u01/oradata/devdb/dev1_01.dbf'
RMNAN> RESTORE DATAFILE '/u01/oradata/devdb/dev1_01.dbf', '/u01/oradata/devdb/dev1_02.dbf' # restoring multiple datafiles
  1. Restore archived redo logs
RMNAN> RESTORE ARCHIVELOG ALL;
  1. Preview the restore
RMAN> RESTORE DATABASE PREVIEW;
  1. Preview summary of restore
RMAN> RESTORE DATABASE PREVIEW SUMMARY;
  1. Validate the backup before restore
RMAN> RESTORE DATABASE VALIDATE;

Happy Learning!