#!/bin/sh
bakdir=/bak/backup/
dt=`date '+%y%m%d'`
if [ `date +%d` = '01' ] #每月1号进行完全备份
then zl=""
#full backup
else zl="-N "`date +'%y-%m-01 00:00:01'`
fi
tmpbakdir=${bakdir}tmp
rm -rf ${tmpbakdir}
mkdir ${tmpbakdir}
if [ -d /app/public-html ] then
tar "${zl}" -czf ${tmpbakdir}/public-html$dt.tgz /app/public-html
mv ${tmpbakdir}/*.* ${bakdir}
fi
#oracle backup
if [ -d /u01/oracle ] then
chmod 777 ${tmpbakdir}
su - oracle -c "exp zzb/zzb file=${tmpbakdir}/oracledmp${dt}.dmp"
mv ${tmpbakdir}/*.* ${bakdir}/
rm -rf ${tmpbakdir}
cd ${bakdir}/
fi
cd &{bakdir}/
ftp -in <<EOF
open 10.10.0.1
user wh wh
bin
put ${bakdir}public-html$dt.tgz ${bakdir}public-html$dt.tgz
put ${bakdir}/oracledmp${dt}.dmp ${bakdir}/oracledmp${dt}.dmp
close EOF