Thursday, October 20, 2011

Shell Script To Take RMAN Cold,Hot and Export Backup

#!/bin/bash
ORACLE_SID=OTM;export ORACLE_SID
echo $ORACLE_SID

echo “Please Specify the kind of backup you want to take”
echo “1) COLD BACKUP”
echo “2) HOT BACKUP”
echo “3) EXPORT BACKUP”
echo “Enter your option”

read option

while [ $option -gt 3 ]||[ $option -le 0 ]
do
echo “Please Enter the correct option”
read option
done

case $option in
1|2) echo “You are taking rman backup of DB”
rman target sys/sys @/oracle/product/11g/rman_backup_$option.txt;exit;;
3) echo “You are taking export backup of DB”
exp system/sys file=/oracle/exp_dat.dmp log=/oracle/exp_dat.log full=y;
exit;;
esac

exit

The above script can call anyone of the following rman script depending upon the user who wants take cold or hot backup

The content of rman_backup_1.txt

run {
shutdown immediate;
startup mount;
allocate channel dup1 device type disk;
allocate channel dup2 device type disk;
backup format ‘/oracle/%U’ database;
release channel dup1;
release channel dup2;
alter database open;
}

The content of rman_backup_2.txt

run {
allocate channel dup1 device type disk;
allocate channel dup2 device type disk;
backup format ‘/oracle/%U’ database;
backup format ‘/oracle/arch_%U’ archivelog all;
backup format ‘/oracle/ctl_%U’ current controlfile;
release channel dup1;
release channel dup2;
}



1 comment: