top of page

Automate RMAN Backup using Shell Script

In a real environment, off course you will not manually trigger all the Oracle database backups. You need an automated mechanism to trigger RMAN backups. In this article, we will look at RMAN backup automation using shell scripts.

Create directory structure

On your database server, create a directory structure to hold RMAN backups and all related files. All the RMAN backups, logs and backup scripts are kept in one directory. If you want to have a different directory structure, its complete up to your environment requirements

mkdir -p /u01/rman

Create RMAN backup script file

Let us create the RMAN backup script file to trigger DB FULL backup

vi /u01/rman/


. /home/oracle/.bash_profile

export ORACLE_SID=proddb
export ORACLE_HOME=/u01/app/oracle/product/
export DATE=$(date +%y-%m-%d_%H%M%S)

rman target / log=/u01/rman/proddb_${DATE}.log << EOF
allocate channel ch1 device type disk format '/u01/rman/proddb_full_bkp_%u';
allocate channel ch2 device type disk format '/u01/rman/proddb_full_bkp_%u';
crosscheck backup;
delete noprompt obsolete;
backup database;
backup archivelog all delete input;
release channel ch1;
release channel ch2;

Schedule Backup Under Crontab

Give execute permissions on the shell script

chmod 775 /u01/rman/

Now you can go ahead and schedule the backup under the crontab. For example, we are

scheduling backup to trigger at 10 am and 4 pm everyday

crontab -e

00 10,16 * * * /u01/rman/

Crontab tool

Here is a crontab handy tool that I use to accurately define when crontab will execute next.

Related Posts

Heading 2

Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

bottom of page