Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Wednesday, July 26, 2017

ESSBASE DATABASE Backups scripts in Unix

#!/bin/ksh
####################################################################
#                                                                  #
#  Who          When            What                               #
#  ----------------------------------------------------------------#
#  shaiks       24-JUL-17       Created
#                                                                  #
#                                                                  #
####################################################################
#

date1=`date +'%d%b%y'`
date2=`date +'%d%b%Y%H%M%S'`

#Set Parameters
if [ ${#} -ne "1" ];then
        echo " Please pass the environment name"
exit 0
else
        ENV=$(echo $1 |tr '[:lower:][:upper:]' '[:upper:][:lower:]')
fi

. /home/hypuser/EPM$ENV.env
if [ $ENV == "DEV" ] || [ $ENV == "TST" ];then
SCRIPTS_DIR=/PATH/scripts
else
SCRIPTS_DIR=/PATH$1/scripts
fi
DATA_BACKUP_DIR=/HYP/$ENV/DATA_BKP
BACKUP_DIR=$DATA_BACKUP_DIR/$date2
LOG_FILE=$BACKUP_DIR/$(basename "$0" | cut -d \. -f1)_$ENV_$date2.log

mkdir -p $BACKUP_DIR
#echo $ENV $date2 $DATA_BACKUP_DIR/$date2/ $SCRIPTS_DIR $LOG_FILE

. /home/hypadm/EPM$ENV.env

startMaxl.sh -D ${SCRIPTS_DIR}/essbase_data_backup_all.mxls ${MAXLPVTKEY} ${MAXLENCRID} ${MAXLENCRPWD}
${ESBSERVER} ${BACKUP_DIR} ${LOG_FILE} ${date2}

#Verify Success or Failure
status=$(grep -i error $LOG_FILE | awk '{print $1}'| uniq)
if [[ $status != "ERROR" ]];then
echo "Success"  | mailx -s "ESSBASE $ENV Backup completed Successfully" shaiksameer@shaiksameer.com
else
uuencode $LOG_FILE $LOG_FILE | mailx -s "ESSBASE $ENV Backup failed - verify the attached log" shaiksameer@shaiksameer.com
fi


#Delete Data backups older than 45 days.
find $DATA_BACKUP_DIR -prune -type d -mtime +45 -exec rm -rf {} \;


cat essbase_data_backup_all.mxls
/*Purpose: Data Back-up of all Essbase Databases */
/*    Log in to Essbase    */
login $key $1 $key $2 on $3;

spool on to "$5";

/*    Disable connection to RPT database */
alter application RPT disable connects;

/*    Back-up Reporting Data   */
export database RPT.RPT data to data_file "$4/RPT_RPT_data_export_$6.txt";

/*    Enable connection to RPT database */
alter application RPT enable connects;

spool off;
logout;
exit;


No comments: