日期:2014-05-16  浏览次数:20950 次

MySQL异地全备份
#bash/sh!
echo "start backup..."
#MySQL Info
sql_user=root
sql_psw=root
sql_db=buke_user
name=$sql_db$(date +%y%m%d).sql
backup_path=/home/backup
file=$sql_db$(date +%y%m%d).tar.gz

#ftp Info
ftp_host=11.1.1.111
ftp_user=root
ftp_psw=root


cd $backup_path
mysqldump --opt $sql_db -u$sql_user -p$sql_psw >  $name
sleep 5s
tar czf $backup_path/$file  $name

sleep 10s

cd $backup_path
ftp -i -n <<!
open $ftp_host
user $ftp_user $ftp_psw
type binary
put $file
close
bye
!

sleep 3s

#rm -r $name
?