You are on page 1of 8

Below is a script to restore Oracle RDBMS Home , Oracle grid home and other /etc config files on a host

from a previous backup. When do we need to use the script? After the HDD of a database host (part of RAC) goes bad and if it had to be replaced and reimaged with new OS, once the OS is installed and eth is set by the SA team, following script can be used to restore the oracle software from a previous backup. How to run the 11g binary restore script: 1) 2) 3) 4) 5) 6) Make sure a previous good and clean backup of the same host exists already under /net/dba/backup/<HOST_NAME> SA to complete the reimage and set up eth interconnect and hand over to the DBAs. Login as root to the newly reimaged host and copy /etc/fstab from other host of the RAC and mount /net/dba Run /net/dba/panama/scripts/backup/restore_11g_homes.sh as root Run /home/oragrid/product/11.2/root.sh as root Startup the instance and relocate services.

Script: (/net/dba/panama/scripts/backup/restore_11g_homes.sh) #!/bin/sh #Script to Restore Oracle Software and related files if [ `whoami` != 'root' ] ; then echo "You must run this program as root. " exit 1 fi THIS_SCRIPT=`basename $0` export ECHO=echo export DEBUG=

export ORACLE_BASE=/home/oracle export GRID_BASE=/home/oragrid export ORACLE_ADMIN=$ORACLE_BASE/admin

export HOSTNAME_NEW=`hostname -s` export COLO=`echo $HOSTNAME_NEW |cut -d - -f1 -s` export NODE_TYPE=`echo $HOSTNAME_NEW |cut -d - -f2 -s` export NODE_NUMBER=`echo $HOSTNAME_NEW |cut -d - -f3 -s` export HOSTNAME=$COLO-$NODE_TYPE-$NODE_NUMBER export BACKUP_DIR=/net/dba/backup/$HOSTNAME echo "Backup directory should be $BACKUP_DIR" export ORACLE_HOME=/home/oracle/product/11.2 export ORACLE_GRID=/home/oragrid/product/11.2 export AGENT_HOME=/oracle/product/agent10g

if [ -d $BACKUP_DIR ] then echo "Successful $BACKUPDIR exists.." else echo " Error: Backup directory $BACKUPDIR does not exist"

exit 1 fi # check if /oracle is a link to /home/oracle #if [ -L /oracle ] #then # echo "/oracle link is already present" #else # echo " create the link /oracle to /home/oracle" # ln -s /home/oracle /oracle #fi if [ -d /home/oracle/product ] then echo "Successful /home/oracle/product exists.." else echo "Creating directory /home/oracle/product" ${DEBUG} mkdir /home/oracle/product ${DEBUG} chown root:root /home/oracle/product fi

if [ -d /home/oragrid/product ] then

echo "Successful /home/oragrid/product exists.." else echo "Creating directory /home/oragrid/product" ${DEBUG} mkdir /home/oragrid/product ${DEBUG} chown root:dba /home/oragrid/product fi #${ECHO} "Create the diag directories" #${ECHO} "--------------------------------------" #if [ -d /home/oracle/diag ] #then # echo "Successful /home/oracle/diag exists.." #else # mkdir /home/oracle/diag ; chown oracle:dba /home/oracle/diag #fi ${ECHO} "Create the monitor directories" ${ECHO} "--------------------------------------" if [ -d /oracle/monitor ] then echo "Successful /oracle/monitor exists.." else mkdir /oracle/monitor ; chown oracle:dba /oracle/monitor ;chmod 777 /oracle/monitor

fi # Create the mount /u01 /u02 etc and mount volumes ${ECHO} "Create the mount /u01 /u02 etc" for MOUNTS in `cat $BACKUP_DIR/etc/fstab |grep u0 |awk '{print $2}'` do mkdir -p $MOUNTS chown oracle:dba $MOUNTS done mount -a ${ECHO} "### Restore (etc/oracle) and (oracle rdbms, oragrid)" ${ECHO} "-----------------------------------------------------" ${DEBUG} rsync -rpogtl $BACKUP_DIR/rdbms/11.2 $ORACLE_BASE/product ${DEBUG} rsync -rpogtl $BACKUP_DIR/oragrid/11.2 $GRID_BASE/product ${ECHO} "### Restore diag dir's" ${ECHO} "-----------------------------------------------------" ${DEBUG} rsync -rpogtl $BACKUP_DIR/diag $ORACLE_BASE ${ECHO} "copy the below etc files & Dir" ${ECHO} "-------------------------------" ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/oraInst.loc /etc ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/fstab /etc ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/oracle /etc/

${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/inittab.crs /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/inittab /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/oratab /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/init.d /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc2.d /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc3.d /etc/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc5.d /etc/

#${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/init.d/init.cssd /etc/init.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/init.d/init.crs /etc/init.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/init.d/init.crsd /etc/init.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/init.d/init.evmd /etc/init.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc2.d/K96init.crs /etc/rc2.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc3.d/S96init.crs /etc/rc3.d/ #${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/rc5.d/S96init.crs /etc/rc5.d/ ${DEBUG} rsync -rpogtl $BACKUP_DIR/var/tmp/.oracle /var/tmp/ ${ECHO} "### Restore (/oracle/product/agent10g, oraInventory)" ${ECHO} "-----------------------------------------------------------" ${DEBUG} rsync -rpogtl $BACKUP_DIR/agent10g $ORACLE_BASE/product ${DEBUG} rsync -rpogtl $BACKUP_DIR/oraInventory $ORACLE_BASE

${ECHO} "copy the below Oracle Dir & files" ${ECHO} "----------------------------------" ${DEBUG} rsync -rpogtl $BACKUP_DIR/.ssh $ORACLE_BASE ${DEBUG} rsync -rpogtl $BACKUP_DIR/.zshrc $ORACLE_BASE ${DEBUG} rsync -rpogtl $BACKUP_DIR/.zshrc /home/gcuser ${DEBUG} chown gcuser:dba /home/gcuser/.zshrc ${DEBUG} rsync -rpogtl $BACKUP_DIR/ORCLfmap /opt

#restore cronfile ${DEBUG} rsync -rpogtl $BACKUP_DIR/oraclecron /var/spool/cron/oracle

#restore osw if [ -d $BACKUP_DIR/osw ] then ${DEBUG} fi rsync -rpogtl $BACKUP_DIR/osw /home/oracle

#restore stunnel if [ -d $BACKUP_DIR/etc/stunnel ]

then ${DEBUG} rsync -rpogtl $BACKUP_DIR/etc/stunnel /etc/ fi ## check for any files...any customized init.d scripts, stunnel configs

You might also like