In this article; i will explain how we can take backup wiht using scriptsMany Oracle Forum users ask question in OTN as ” where we can find scripts for backup”. I want to share some sample script code for can take Oracle E-Business Suite.

Before start please change related information wiht yours instead of in sample code

1. Cold backup script:

BKUP_DATE=`date +%d%m%Y`
export BKUP_DATE

BKUP_LOG_FILE=/xx/log_backup_”$BKUP_DATE”.log
export BKUP_LOG_FILE

echo “##########STOPPING ORACLE SERVICES################” >> $BKUP_LOG_FILE
/xx/oraclectl.sh stop >> $BKUP_LOG_FILE
echo “##########DONE Stopping Oracle Services###########”  >> $BKUP_LOG_FILE
sleep 60
echo “##########COPYING DATABASE DIRECTORIES############”  >> $BKUP_LOG_FILE
/xx/backup_to_disk.sh
echo “##########DONE Copying Database Directories#######”  >> $BKUP_LOG_FILE
sleep 120
echo “##########STARTING ORACLE SERVICES################”  >> $BKUP_LOG_FILE
/xx/oraclectl.sh start >> $BKUP_LOG_FILE
echo “##########DONE Starting Oracle Services###########”  >> $BKUP_LOG_FILE

echo “##########DELETE OLD BACKUP LOGS #################”  >> $BKUP_LOG_FILE
find . -name ‘log_backup*’ -mtime +3 -exec rm -f {} \;  >> $BKUP_LOG_FILE
echo “##########DONE Delete Old Backup Logs ############”  >> $BKUP_LOG_FILE

/bin/mailx -s “XX company ORACLE DB COLD BACKUP LOG – ” abc@xx.com < $BKUP_LOG_FILE

As you can see we are using oraclectl.sh for can stop/start services.

The details of this sh is:

ORA_OWNER_DB=oraprod
ORA_SID_DB=PROD
ORA_HOSTNAME=xx
ORACLE_HOME=/xx/PROD/proddb/9.2.0

ORA_OWNER_APP=applprod
COMMON_TOP=/xx/PROD/prodcomn

SID_HOST=PROD_xx

case “$1” in
‘start’) # Start the Oracle e-Business Suite Services
su – $ORA_OWNER_DB -c “$ORACLE_HOME/appsutil/scripts/$SID_HOST/addbctl.sh start”
su – $ORA_OWNER_DB -c “$ORACLE_HOME/appsutil/scripts/$SID_HOST/addlnctl.sh start $ORA_SID_DB”
su – $ORA_OWNER_APP -c “$COMMON_TOP/admin/scripts/$SID_HOST/adstrtal.sh apps/apps”
;;
‘stop’)  # Stop Oracle e-Business Suite Services
su – $ORA_OWNER_APP -c “$COMMON_TOP/admin/scripts/$SID_HOST/adstpall.sh apps/apps”
sleep 240
su – $ORA_OWNER_DB -c “$ORACLE_HOME/appsutil/scripts/$SID_HOST/addlnctl.sh stop $ORA_SID_DB”
su – $ORA_OWNER_DB -c “$ORACLE_HOME/appsutil/scripts/$SID_HOST/addbctl.sh stop immediate”
;;
esac

As you can see we are using backup_to_disk.sh for can copy process

#Delete first previous cold backup

rm -rf /xx/backup/offline_backup/*

#Start to copy process for cold backup

cp -rf /xx/PROD/proddata /xx/backup/offline_dbbckp

cp -rf /xx/PROD/proddb  /xx/backup/offline_dbbckp

After  edit and replace your system’s exact informations(like user,path etc.) instead of my information which i have used for my script than you can use it with crontab future and can  schedule for your cold backup

Reklam