#!/bin/bash

### make by chinaiswell

mkdir -p /root/allsite

backupdir=/root/allsite

Today=`date +%m%d`

ftp_hostname=*.*.*.*:port

ftp_user=*****

ftp_password=l2324

mail_to=************@qq.com

for website in `ls /home/`;do

tar czvPf $backupdir/$website.tar.gz /home/$website/public_html;

done

mysql  -e "select schema_name from information_schema.schemata where schema_name not in ('information_schema','mysql')" >db_list.log

while read db_name

do

  if [ $db_name != 'schema_name' ]

  then

    mysqldump --opt $db_name >$backupdir/$db_name.sql

    tar zcf /$backupdir/$db_name-$Today.sql.gz /$backupdir/$db_name.sql    

  fi

done <db_list.log

rm -rf $backupdir/*.sql

lftp $ftp_hostname -u $ftp_user,ftp_password <<EOF

lcd $backupdir

mkdir $Today

mput -O $Today *

EOF

rm -rf $backupdir

echo "All databases and website were backup complete!!!!"|mail -s "A Backup Completed Notice" $mail_to