#!/bin/bash
#author:zwy
#2016-12-15
#auto backup db ypsh
dt=`date "+%Y_%m_%d"`
prefix="ypsh_"
suffix='.sql'
xname=${prefix}${dt}${suffix}
echo $xname
mysql_dir="/usr/local/mysql/bin/"
db_bak_dir="/root/ypsh_db_bak/"
cd $mysql_dir
echo `pwd`
./mysqldump -hlocalhost -uroot -pabcedf. ypsh >/root/ypsh_db_bak/$xname
cd $db_bak_dir
echo `pwd`
tar_xname=${xname}".tar.gz"
echo $tar_xname
tar -zcvf $tar_xname $xname
ip="172.29.0.182"
user="zwf_2016"
passwd="abcedf9527"
lftp <<!
open $ip -u $user,$passwd
put $tar_xname
close
bye
!