Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Sunday, 7 October 2012

A Shell Script To Take RMAN Cold/Hot and Export Backup

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

echo “Which kind of backup you want to take?”
echo “1) RMAN COLD BACKUP”
echo “2) RMAN HOT BACKUP”
echo “3) LOGICAL OR 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 shaan Database”
   rman target sys/oracle@shaan @/ORACLE/RMAN_BACKUP/rman_backup_$option.txt;exit;;
3) echo “You are taking export backup of shaan Database”
   exp system/oracle file=/ORACLE/EXPORT_BACKUP/exp_dat.dmp log=/oracle/export_backup/exp_dat.log full=y;
   exit;;
esac

exit

# Now Create two simple text file for Rman Cold and Hot backup.
# The above script can call anyone of the following RMAN script depending on the option 1-cold or 2-hot backup.

rman_backup_1.txt:

run
{
shutdown immediate;
startup mount;
allocate channel d1 type disk FORMAT "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db";
allocate channel d2 type disk FORMAT "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db";
backup full format "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db" (database);
copy current controlfile to 'H:\Cold_Backup\COLD_BACKUP_Control.db';
release channel d1;
release channel d1;
alter database open;
}

rman_backup_2.txt:

run {
allocate channel d1 type disk FORMAT "H:\Hot_Backup\Hot_BACKUP_%T_%d-%s_%p.db";
allocate channel d2 type disk FORMAT "H:\Hot_Backup\Hot_BACKUP_%T_%d-%s_%p.db";
sql 'alter system archive log current';
backup

tag Catalog_Full_Rman
filesperset 10
format "H:\Hot_Backup\Hot_Backup_%T_FULL_%d-%s_%p.db"
database archivelog all;
release channel d1;
release channel d1;
}

3 comments:

  1. Assalamo Alaikum

    Brother very nice, Please carry on. Thanks

    Brother I want to give one suggestion if you donot mind. Please update the script according to oracle version 11g. Because new features have introduced in RMAN & Others.

    You way of explain is very nice. So I give above suggestion.

    Thank you very much for your nice explain

    Md. Tanweer
    0508838173

    ReplyDelete
    Replies
    1. Thanks for appreciation. It is not matter for ant thing to mind. I am not usually using 11g ‎infact. We have all the production database in oracle 9i and 10g. I have tested all of this ‎blog scripts on 9i/10g. If you have any thing to add either you can add directly on ‎particular article with the version or send to me.‎

      Delete
  2. Nice one...

    We have oracle 9i database on AIX and all datafiles are created using LV.
    Like we have Logical groups called rootvg, prodvg. whenever we want create new data file first we will create Logical volume in PRODVG and we will create soft link it.
    ln -s /dev/rg_sales_index2048F sales_index.1

    Suppose i want take backup which one will be good export or rman.
    and How to take cold backup. Please suggest me.

    Thanks,
    Krishna

    ReplyDelete