• Arun Kumar

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/full_backup.sh

. /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';
allocate channel ch3 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;
release channel ch3;

Schedule Backup Under Crontab

Give execute permissions on the shell script

chmod 775 /u01/rman/full_backup.sh

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/full_backup.sh

Crontab tool

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


Recent Posts

See All

MySQL Installation on Linux

This article demonstrates MySQL installation on Oracle Enterprise Linux 6.5 version. Installation of MySQL Make sure you are able to connect internet via virtual machine. Try to ping google.com and pr

Add ISO image storage repository on XenServer

If you have used VMware ESXI, its very easy to upload ISO files to the data store and create VMs. With XenServer, you must create your own ISO repository to upload ISO files. Create ISO directory Acce

Perform Manual Switchover on Physical Standby

Connect to proddb database via client: Take a new putty session and connect to proddb database via client machine. Keep querying below sqlplus sys/sys@proddb as sysdba SQL> select name, open_mode, db

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis