exp test/test file=/home/oracle/local/test`date +%y%m%d`.dmp log=/home/oracle/local/log/backup.log
#检查日志文件,查看备份是否成功
result=`cat /home/oracle/local/log/backup.log|grep 'Export terminated successfully with warnings.'`
#如果备份成功,则将备份文件通过sftp上传至WEB服务器中保存
if [ "$result" ]
then
cd /home/oracle/local/
HOST=192.168.1.101
USER=test
PASS=test123
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
cd /home/testbackup/
put test`date +%y%m%d`.dmp
bye
EOF
echo "done"
rm -rf `find /home/oracle/local -mtime +1|grep test`
rm -rf `find /home/oracle/local/log -mtime +1|grep test`
#将本次备份日志文件标注保存
mv /home/oracle/local/log/backup.log /home/oracle/local/log/test`date +%y%m%d`.log
#如果备份失败,生成日志文件,并发送邮件通知
else
echo 'the exp failed'>/home/oracle/local/log/errorExp`date +%y%m%d`.log
service sendmail restart
mail -v -s "The `hostname` data exp failed!" [email]niu8878@163.com[/email]</home/oracle/local/log/errorExp`date +%y%m%d`.log
sleep 60
service sendmail stop
fi