邮件服务器备份脚本。适合于EXTMAIL
时间:2008-04-13 来源:huzi1986
#!/bin/sh
backupdir="/home/data/backup/"
if [ ! -d $backupdir ];then
mkdir -p $backupdir
fi
# mkdir today backup
today=`date +%Y-%m-%d`
fpath=$backupdir$today
echo $fpath
if [ ! -d $fpath ];then
mkdir $fpath
fi
# delete old file
find $backupdir -type f -mtime +5 -print -exec rm {} \;
FL=`cat /home/file_list`
for i in $FL ;do
cp -Rp $i $fpath
done
#backup mail dir
cp -Rp /home/domains $fpath
# backup mysql all
/usr/bin/mysqldump --all-databases -uroot -pdayuweiwei >$fpath/mysql_all.sql
# backup my self
cp -Rp $0 $fpath
cp -Rp /home/file_list $fpath
cd $backupdir
tar czf $today.tar.gz $today
rm -rf $today
cd -
# ftp ...
ftp -n<<!
open 192.168.0.12 21
user huzi dayuweiwei
binary
lcd $backupdir
prompt off
mput $today.tar.gz
bye
!