Search

Thursday, June 23, 2016

Oracle RMAN full backup script to disk with compression

In this article I’ll share an RMAN script to backup the entire Oracle database including archived redo logs to disk using compression. Before looking into the script see my notes below:
– Script should work for Oracle 10g and 11g
Oracle database name = ORCL
– I use 4 RMAN channels to speed up the backup
– I backup intentionally control file manually and automatically
– I limit the size of backup sets by number of files per set and size of backup sets
– I use backup compression in RMAN script (Oracle Advanced Compression license is required)
– The average compression factor can be different but to give you an idea it can be around 7.
– This script is independent from RMAN configuration parameters

# Last update: 14-Mar-2013
#
connect target /
sql 'alter system archive log current';
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
configure controlfile autobackup on;
set command id to 'ORCLOnlineBackupFull';
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
ALLOCATE CHANNEL c2 DEVICE TYPE disk;
ALLOCATE CHANNEL c3 DEVICE TYPE disk;
ALLOCATE CHANNEL c4 DEVICE TYPE disk;
backup AS COMPRESSED BACKUPSET full database tag ORCL_FULL format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_FULL' ;
sql 'alter system archive log current';
backup tag ORCL_ARCHIVE format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_ARCHIVE' archivelog all delete all input ;
backup tag ORCL_CONTROL current controlfile format '/opt/oracle/backups/ORCL/%d_%T_%s_%p_CONTROL';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}


I find also valuable the below RMAN backup summary report that gives you an idea what backup sets are created as a result of running that RMAN script.

RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
5421 B F A DISK 22-MAR-13 1 1 YES ORCL_FULL
5422 B F A DISK 22-MAR-13 1 1 YES ORCL_FULL
5423 B F A DISK 22-MAR-13 1 1 YES ORCL_FULL
5424 B F A DISK 22-MAR-13 1 1 YES ORCL_FULL
5425 B F A DISK 22-MAR-13 1 1 NO TAG20130322T182553
5426 B A A DISK 22-MAR-13 1 1 NO ORCL_ARCHIVE
5427 B A A DISK 22-MAR-13 1 1 NO ORCL_ARCHIVE
5428 B F A DISK 22-MAR-13 1 1 NO ORCL_CONTROL
5429 B F A DISK 22-MAR-13 1 1 NO TAG20130322T182603

I encourage readers to share / comment own commands and tips on the similar Oracle RMAN full backup script in this post. And I’ll continue with more RMAN scripts in the next articles.