#!/bin/bash
. /home/oracle/.bash_profile
export script_dir=/u01/app/script
export DATA_PUMP_DIR=/backup/data_pump_dir
export DEST_DIR=/datastore/FCCLIVE
cd /u01/app/script
datevar=`date +%Y%m%d%H%M`
sed 's/<DATE>/'$datevar'/g' <FCCHOST_FCCLIVE_template.par >FCCHOST_FCCLIVE.par
export ORACLE_SID=FCCLIVE
sqlplus /nolog <<EOF
conn /as sysdba
set feedback off
set head off
set line 200
set pagesize 100
col object_type format a18
col status format a15
select object_type,status,count(*)
from dba_objects
where owner = 'FCCHOST'
group by object_type,status
/
exit;
EOF
expdp \' \/as sysdba \' parfile=FCCHOST_FCCLIVE.par
# Sending mail #
sqlplus /nolog <<EOF
conn /as sysdba
BEGIN
UTL_MAIL.send(sender => 'oracle@ababank.com',
recipients => 'dba@ababank.com;FlexcubeSupport@ababank.com',
subject => '[' || SYS_CONTEXT ('USERENV', 'DB_NAME') || '] Backup PREEOD '|| $(echo $datevar)||' Completed',
message => '<PRE>"$(tail -40 ${DATA_PUMP_DIR}/FCCHOST_FCCLIVE_PREEOD_${datevar}.log)"</PRE>',
mime_type => 'text/html;charset=us-ascii');
END;
/
--create restore point BEFORE_RUN_EOD guarantee flashback database;
exit;
EOF
# Copy to Backup 10.152.1.52 #
scp ${DATA_PUMP_DIR}/FCCHOST_FCCLIVE_PREEOD_${datevar}* oracle@10.152.1.52:${DEST_DIR}
# deleting part #
grep "FCCHOST_FCCLIVE" ${DATA_PUMP_DIR}/FCCHOST_FCCLIVE_PREEOD_"$datevar".log|awk -F'/' '{print $4}' > filelist.txt
for filename in $(cat filelist.txt); do
a=`ssh oracle@10.152.1.52 ${DEST_DIR}"/FCCLIVE_dump_exist_check.sh "$filename`
if [ "$a" = "File is existing" ]
then
rm ${DATA_PUMP_DIR}/$filename
fi
done
touch $script_dir/running_preeod_expdp_done.flg
if [ -f $script_dir/running_preeod_expdp.flg ]
then
rm $script_dir/running_preeod_expdp.flg
fi
exit 1
No comments:
Post a Comment