标签:
#!/bin/bash
time=`date +%Y%m`
day=`date -d ‘-1 days‘ +%Y%m%d`
localDir="/DBBackup/GameDB"
cd $localDir
#ip_game.ini配置ftp服务器的ip,账号,密码等,格式自己定义
#比如:Server1 username userpasswd 1.1.1.1 Dbbackup
servername=(`cat /DBBackup/ip_game.ini | awk -F " " ‘{print $1}‘`)
user=(`cat /DBBackup/ip_game.ini | awk -F " " ‘{print $2}‘`)
passwd=(`cat /DBBackup/ip_game.ini | awk -F " " ‘{print $3}‘`)
ip=(`cat /DBBackup/ip_game.ini | awk -F " " ‘{print $4}‘`)
dbname=(`cat /DBBackup/ip_game.ini | awk -F " " ‘{print $5}‘`)
if [[ -z $time ]]
then
cd $time && mkdir $day
else
mkdir $time
cd $time && mkdir $day
fi
len=${#ip[*]}
num=0
while [ $num -lt $len ]
do
echo "=======${user[$num]}==========="
echo "=======${passwd[$num]}========="
echo "=======${ip[$num]}========="
cd $localDir/$time/$day
if [[ -z ${servername[$num]} ]]
then
cd ${servername[$num]}
else
mkdir ${servername[$num]}
fi
lftp ftp://${user[$num]}:"${passwd[$num]}"@${ip[$num]} <<END
lcd $localDir/$time/$day/${servername[$num]}
cd ${dbname[$num]}
echo ${dbname[$num]}
#mget empiregame_*_$(date +%Y%m%d).rar
mget empiregame_*_$(date -d ‘-1 days‘ +%Y%m%d)*.tar.gz
mget empireaccount_$(date -d ‘-1 days‘ +%Y%m%d)*.tar.gz
mget empirecards_$(date -d ‘-1 days‘ +%Y%m%d)*.tar.gz
mget empiregame_*_$(date -d ‘-1 days‘ +%Y%m%d)*.rar
bye
END
let num++
done
标签:
原文地址:http://www.cnblogs.com/franjia/p/4384109.html