How to take RMAN Backup using Shell Script


Create directory structure to keep rman backup


mkdir -p /oracle/stage/rman



Create RMAN backup script file


RMAN backup script to take  DB FULL backup


vi /home/oracle/full_backup.sh


#!/bin/bash


. /home/oracle/.bash_profile


export ORACLE_SID=PROD

export ORACLE_HOME=/u01/app/oracle/product/11.2.0

export DATE=$(date +%y-%m-%d_%H%M%S)


rman target / log=/home/oracle/prod_${DATE}.log << EOF

run

{

allocate channel ch1 device type disk format '/oracle/stage/rman/prod_full_bkp_%u';

allocate channel ch2 device type disk format '/oracle/stage/rman/prod_full_bkp_%u';

delete noprompt obsolete;

backup database;

backup archivelog all delete input;

release channel ch1;

release channel ch2;

}

EOF



Schedule Backup Under Crontab


Give execute permissions on the shell script


chmod 775 /home/oracle/full_backup.sh


crontab -e


Schedule to run at 11 PM Daily


00,23 * * * /home/oracle/full_backup.sh





If you like please follow and comment