RMAN backup script

Need an RMAN backup script?
This is an RMAN script to backup the entire database and archived redo logs for a non-RAC and RAC environments.

In this example we will save the script in a file called "backup.rcv". The script contains disk location which can be changed according to your specific environment.

 

----------------- backup.rcv for non-RAC -----------------

 run
{
    allocate channel c1 type disk format '/oracle/backup/rman_db_%T_%U.rman';

    backup as compressed backupset full database include current controlfile;
    release channel c1;
    allocate channel c1 type disk

        format '/oracle/backup/rman_arc_%T_%U.rman';
    sql "alter system archive log current";
    delete noprompt archivelog all backed up 2 times to device type disk;
    backup as compressed backupset archivelog all;
    sql "alter database backup controlfile

        to ''/oracle/backup/rman_control.rman'' reuse";
    release channel c1;
}
----------------- end of backup.rcv -----------------

 

----------------- backup.rcv for RAC -----------------

run
{
    allocate channel c1 type disk format '/oracle/backup/rman_db_%T_%U.rman'

        connect 'sys/sys@node1';
    backup as compressed backupset full database include current controlfile;
    release channel c1;
    allocate channel c1 type disk format '/oracle/backup/rman_arc_%T_%U.rman'

        connect 'sys/sys@node1';
    allocate channel c2 type disk format '/oracle/backup/rman_arc_%T_%U.rman'

        connect 'sys/sys@node2';
    sql "alter system archive log current";
    delete noprompt archivelog all backed up 2 times to device type disk;
    backup as compressed backupset archivelog all;
    sql "alter database backup controlfile

        to ''/oracle/backup/rman_control.rman'' reuse";
    release channel c1;
    release channel c2;
}
----------------- end of backup.rcv -----------------

 

Now, to use this script just execute:

 

rman target / cmdfile=backup.rcv

Subscribe for updates

If you want to know when new videos or articles are added to DBSnaps, subscribe for updates here

Name
E-mail