Wednesday, 26 July 2017

RMAN Incremental Backup Script for Oracle Database

RMAN Incremental Backup Script for Oracle Database - Level 1 Backup


RMAN Script to take Incremental Oracle database Backup (L1) as well as delete the unwanted backups and archive logs

Please find below the script:


run {
    allocate channel ch1 type disk connect 'sys/********@db_name' ;
    allocate channel ch2 type disk connect 'sys/********@db_name' ;
    allocate channel ch3 type disk connect 'sys/********@db_name' ;
    allocate channel ch4 type disk connect 'sys/********@db_name' ;
    allocate channel ch5 type disk connect 'sys/********@db_name' ;
    allocate channel ch6 type disk connect 'sys/********@db_name' ;
    crosscheck backup;
    crosscheck archivelog all;
    sql "alter session set optimizer_mode=Rule " ;
SQL 'alter system archive log current';
backup skip inaccessible filesperset 8 format '/LOCATION/rman_arch_L1_%s_%D%M%Y' (archivelog until time 'sysdate-3' delete input);
SQL 'alter system archive log current';
backup copies 2
incremental level 1
tag bkp_level_1
format '/LOCATION/rman_L1_%s_%D%M%Y','/LOCATION/rman_L1_%s_%D%M%Y'
database;
    delete noprompt obsolete;
    delete noprompt expired archivelog all;
    delete noprompt expired backup;
    crosscheck backup;
    crosscheck archivelog all;
    SQL 'alter system archive log current';
    Backup skip inaccessible filesperset 8 format '/LOCATION/rman_arch_L1_%s_%D%M%Y' (archivelog all not backed up 1 times);
    backup copies 2 format '/LOCATION/rman_ctlfile_L0_%s_%D%M%Y','/LOCATION/rman_ctlfile_L1_%s_%D%M%Y' current controlfile;
    report need backup;
    release channel ch1;
    release channel ch2;
    release channel ch3;
    release channel ch4;
    release channel ch5;
    release channel ch6;
    }

The above script will perform the below mentioned activities:

  • allocate 6 different channels to boost up the Backup Speed
  • crosscheck all the backups and archivelogs
  • change the optimizer rules
  • switching logfiles on all the instances
  • delete all the archives created more than 3 days ago
  • backup database (incremental)  as backupset
  • backup current controlfile
  • release the allocated channels
Note:- Formatting Backups helps you naming backups properly and helps you recognize them easily. Not only for backups, use formats wherever possible as these are only going to make your work a lot easier.

This is just a short overview for what this script will do for you. You can modify it and make changes to the same as per your requirement.

No comments:

Post a Comment