Linux batch remote multi-server FTP and download file scripts

Source: Internet
Author: User

#!/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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.