This script is used to take backup of oracle application home in specific mount point. First it will check the size of apps home and calculate the mount point future used space in percentage based on result it will make a decision to take backup or not.
script:
#!/bin/bash
T=100
mnt=/u02
app_homebkp=/u02/apps_bkp/appshome_bkp`date +%d%m%Y`.log
F=`(df -h $mnt | tail -1|awk ‘{print $6}’)`
if [ “$F” ]
then
USED=`(df -h /u02 | tail -1|awk ‘{print $3}’ | tr -d ‘G’)`
APPSIZE=`(du -sh /u02/prod/apps |awk ‘{print $1}’ | tr -d ‘G’)` ##apps home location###
MOUNTSIZE=`(df -h /u02 | tail -1|awk ‘{print $2}’ | tr -d ‘G’)`
TOT=$(( $USED + $APPSIZE +30 ))
P=$(( $TOT * 100 ))
PER=$(( $P / $MOUNTSIZE ))
if [ “$PER” -le “$T” ]
then
echo -e “\e[1;32m ***************APPL_BKP STARTED:`date`********************* \e[0m” >>$app_homebkp
cd /u02/prod
tar -cvf /u02/apps_bkp/appshome_bkp`date +%d%b%Y` apps >>$app_homebkp
echo -e “\e[1;32m ********APPSHOME_BKP SUCCESSFULLY COMPLETED:`date`********* \e[0m” >>$app_homebkp
else
echo -e “\e[1;31m ******NOT ENOUGH SPACE AVAILABLE TO START APPSHOME_BKP**** \e[0m” >>$app_homebkp
fi
else
echo -e “\e[1;31m *******************MOUNT POINT IS MISSING***************** \e[0m” >>$app_homebkp
fi