Wednesday 26 July 2017

RMAN Script to take full database Backup | Oracle Database

RMAN Script to take full database Backup L0- Oracle Database


RMAN Script to take full Oracle database Backup or also called as Level 0 Backup 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;
    delete noprompt obsolete;
    SQL 'alter system archive log current';
    backup skip inaccessible filesperset 8 format '/LOCATION/rman_arch_L0_%s_%D%M%Y' (archivelog until time 'sysdate-3' delete input);
    SQL 'alter system archive log current';
     backup as compressed backupset copies 2
    incremental level 0
    tag bkp_level_0
    format '/LOCATION/rmanbkp_L0_%s_%D%M%Y','/LOCATION/rman_L0_%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_L0_%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_L0_%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
  • delete all the obsolete files
  • delete all the archives created more than 3 days ago
  • backup database 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