RMAN oracle database 12c backup script

Change RMAN backup location

configure channel device type disk format '/data/backup/%U' maxpiecesize 2 G;

SPFILE backups

The SPFILE can be automatically backed up with the control file during database backups by configuring the CONTROLFILE AUTOBACKUP parameters

To backup up the SPFILE explicitly use:

RMAN> BACKUP SPFILE;


Controlfile backups

The current controlfile can be automatically backed up by the BACKUP command by configuring the CONTROLFILE AUTOBACKUP parameters

To backup the current controlfile explicitly use:

RMAN> BACKUP CURRENT CONTROLFILE;


Datafile backups

To backup a specific data file use BACKUP DATAFILE. For example:

RMAN> BACKUP DATAFILE '/data/app/oradata/TEST/users01.dbf';
Altermatively specify the data file number. For example:

RMAN> BACKUP DATAFILE 5;


Archive log backup

BACKUP ARCHIVELOG ALL;


Archive log backup with delete input

BACKUP ARCHIVELOG ALL DELETE INPUT;


Tablespace Backups

To backup a tablespace use the BACKUP TABLESPACE command. For example:

RMAN> BACKUP TABLESPACE USERS;


To create an image copy of a specific datafile use:

RMAN> BACKUP AS COPY DATAFILE 4 FORMAT '/u01/app/oracle/copy/users01.dbf';


Incremental Backups
By default backups are full (level 0). Backups can also be incremental (level 1).

Incremental backups can be:

Differential - includes all changes since the last full or incremental backup
Cumulative - includes all changes since the last full backup
Differential backups require less space. Cumulative backups are faster to restore

Differential backups are the default.

Level 0 Backup - Backup of spfile,control file ,database and archivelog

RUN
{
  ALLOCATE CHANNEL ch11 TYPE DISK MAXPIECESIZE 10G;
  ALLOCATE CHANNEL ch12 TYPE DISK MAXPIECESIZE 10G;
  ALLOCATE CHANNEL ch13 TYPE DISK MAXPIECESIZE 10G;
  BACKUP
  FORMAT '/data/rman/%d_D_%T_%u_s%s_p%p'
  INCREMENTAL LEVEL 0 DATABASE
  CURRENT CONTROLFILE
  FORMAT '/data/rman/%d_C_%T_%u'
  SPFILE
  FORMAT '/data/rman/%d_S_%T_%u'
  PLUS ARCHIVELOG
  FORMAT '/data/rman/%d_A_%T_%u_s%s_p%p';
  RELEASE CHANNEL ch11;
  RELEASE CHANNEL ch12;
  RELEASE CHANNEL ch13;
}

Level 1 backup


RUN
{
  ALLOCATE CHANNEL ch11 TYPE DISK MAXPIECESIZE 10G;
  ALLOCATE CHANNEL ch12 TYPE DISK MAXPIECESIZE 10G;
  ALLOCATE CHANNEL ch13 TYPE DISK MAXPIECESIZE 10G;
  BACKUP
  FORMAT '/data/rman/%d_D_%T_%u_s%s_p%p'
  INCREMENTAL LEVEL 1 DATABASE
  CURRENT CONTROLFILE
  FORMAT '/data/rman/%d_C_%T_%u'
  SPFILE
  FORMAT '/data/rman/%d_S_%T_%u'
  PLUS ARCHIVELOG
  FORMAT '/data/rman/%d_A_%T_%u_s%s_p%p';
  RELEASE CHANNEL ch11;
  RELEASE CHANNEL ch12;
  RELEASE CHANNEL ch13;
}


RMAN Point in time restoration.

Consider following example, here we are performing DBPITR to the date time : 27-Jan-2019 15:00:00

RMAN> shutdown immediate;

RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 408981760 bytes
Fixed Size 3212896 bytes
Variable Size 392941024 bytes
Database Buffers 109051904 bytes
Redo Buffers 4775936 bytes



For DBPITR "set until time" clause used:

RMAN> RUN {
set until time "to_date('27-JAN-2019 15:00:00′,'DD-MON-YYYY HH24:MI:SS')";
restore database;
recover database;
alter database open resetlogs; }

Share and Enjoy !

0Shares
0 0 0

Recommended For You

ankushthavali

About the Author: ankushthavali

Leave a Reply

Your email address will not be published. Required fields are marked *