数据库脚本备份和远程下载
服务器端备份:
while [ -n "$1" ]; do
datestr=$1
shift 1
done
if [ -z ${datestr} ]; then
datestr=`date +'%Y%m%d'`
fi
#备份数据库
mysqldump -h127.0.0.1 -uuser -ppassword --database test > /home/bakdir/bak/db_${datestr}.sql
备份服务器下载:
while [ -n "$1" ]; do
datestr=$1
shift 1
done
if [ -z ${datestr} ]; then
datestr=`date +'%Y%m%d'`
fi
cd /home/username/bakdir
#备份
lftp -u username,password sftp://host:port <<EOF
get /home/bakdir/bak/db_${datestr}.sql
by
EOF