#!/bin/bash
Time= ' Date +%y%m '
Day= ' date-d '-1 days ' +%y%m%d '
Localdir= "/dbbackup/gamedb"
CD $localDir
#ip_game. INI configuration FTP server IP, account, password, etc., the format of their own definition
#比如: Server1 username userpasswd 1.1.1.1 Dbbackup
Servername= (' Cat/dbbackup/ip_game.ini | awk-f ' "' {print $} ')
User= (' Cat/dbbackup/ip_game.ini | awk-f ' "' {print $} ')
Passwd= (' Cat/dbbackup/ip_game.ini | awk-f ' "' {print $} ')
ip= (' Cat/dbbackup/ip_game.ini | awk-f ' "' {print $4} ')
Dbname= (' Cat/dbbackup/ip_game.ini | awk-f ' "' {print $} ')
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
Linux batch remote multi-server FTP and download file scripts