Thursday, July 9, 2020

Ready RMAN Backup Script To Schedule from Crontab

This shell script can help you schedule RMAN full backup from the Crontab:

In case you are interested in an interactive script to run it manually then use this script:

For the first script before you schedule it to run in the crontab you have to do the following:

Modify the following mandatory parameters at the top of the script to match your database environment details you want to back up:

ORACLE_SID=orcl              The instance name you want to back up. i.e. orcl
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 The Oracle Home location i.e. /u01/app/oracle/product/11.2.0/dbhome_1
BACKUPLOC=/backup        The Backup location "Full path". i.e. /backup

If you still have time you can modify the optional parameters:

COMPRESSION=Y             In case you want to enable compression i.e. enabled
BKP_RETENTION=7          Backups older than 7 days will be deleted. [MAINTENANCEFLAG must =Y for this parameter to take effect]
ARCH_RETENTION=7       Archivelogs older than 7 days will be deleted. [MAINTENANCEFLAG must =Y for this parameter to take effect]
CTRL_AUTOBKP_RETENTION=7 Controlfile autobackup files older than 7 days will be deleted.  [MAINTENANCEFLAG must =Y for this parameter to take effect]
MAINTENANCEFLAG=N  If enabled it will perform the following tasks: [Default Disabled]
                                                - Enable CONTROLFILE AUTOBACKUP mode.
                                                - Enable backups to be resumed if crashed.
                                                - Maintain the good naming of the CONTROLFILE backup piece.
                                                - Crosscheck old backups.
                                                - Crosscheck Archivelog files.
                                                - Delete Expired old backups from the disk. [Based on the Backup retention you defined]
                                                - Delete Obsolete backups which are no more exist from the catalog.
                                                - Delete the old Archivelogs. [Based on the Archivelog retention you defined]
                                                - Delete the old Controlfile backups. [Based on the Controlfile retention you defined]

That's all!

This script is part of the DBA BUNDLE, to read more about it please visit this link:


GitHUB Version: 


  1. Mahmmoud can you describe good rman backup strategies for large databases?

  2. This depends on how much time the backup will take, backup storage cost/license and how critical the DB is and it's Service Level Agreement (SLA).

    In general, For the DBs that take less than 2 hours to fully backup, I prefer to have a daily Incremental 0 backup and archivelog backup every 1-4 hours (depends on the SLA's).

    For the DBs that takes longer than 2 hours for a full backup I prefer the following:
    - Incremental 0 backup once a week.
    - Incremental 1 backup every day.
    - Archivelogs backup every 4 hours.

    I always prefer keeping the archivelogs on disk for at least 24 hours, UNDO RETENTION from 6 to 24 hours and keep FLASHBACK ON as possible.

  3. it would be perfect if yu include incremental strategy and sbt support

  4. is it possible to include incremental / tape support in the script ?

  5. Hi Sam,
    Honestly I would like to make the script compatible with tape backup but this is very difficult to accomplish, because every Media Management software has it own unique parameters that need to be passed to the script. e.g. here are the parameters that are need for one Media Management software "HPDP"
    parms 'SBT_LIBRARY=xxxx
    send channel 'ch1' 'OB2BARTYPE=xxxx';
    send channel 'ch1' 'OB2APPNAME=xxxx'
    send channel 'ch1' 'OB2BARLIST=xxxx;

    It's almost impossible for me to speculate the right parameters for each Media Management software, because they are a lot, moreover many of these parameters values are being changed based on how the Media Management software (either Server or Client) been set up; each environment has its own specific settings.

    I believe it's better to leave the user to change the channel parameters himself in case he/she wants to back up to a tape.

  6. Hi Mahmmoud , Thanks for the feedback . you dont need to make any fixed parameters for tape , its just a parameter if its tape backup let the user define the channel | env parameters manually like $ORACLE_SID , $ORACLE_HOME ... etc

    and how about the incremental backup option ?

    thanks for your support.