Download multiple files from ftp server with bash script
9,865
You could cd into the directory then use mget
command to get all files in that directory:
ftp -in ftp://user:[email protected] << EOF
binary
cd Datenbankbackup
mget *
EOF
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
I have 2 or 3 FTP Servers where our hoster puts database backups each day. Since he only keeps one, I was orded to write a bash script for downloading alle database backups every day so we have more than the one day old backup.
I tried to get it working with ftp command, but since it seems I can't download an complete directory I thought I could do it with a for loop but that won't work with the ftp command and I always get an unxpected end of file error.
I should say, only can connect via ftp on the server. No SSH access or something else!
At the moment I have this:
echo "Download all the database backups from honds ftp-servers" SERVERS="ftp.srv1.de ftp.srv2.de" #for SERVER in $SERVERS; do ftp -in ftp://user:[email protected] << EOF binary get Datenbankbackup EOF
-
Admin over 9 yearsWell would be a good Idea, but I don't have access via ssh to the ftp server. I can only connect via the ftp command or any other ftp client. And via the ftp command I can't tar the files.
-
Admin over 9 yearsYeah sorry, I forget that. I edited that already.
-
-
Admin over 9 yearsWell, that was pretty obviously, why didn't I thought about that... thanks, does what it should