从FTP服务器下载所有文件

时间:2023-01-14 11:13:22

I need to download everything from an FTP server to hosting on a different server. I have shell access only to the server I'm downloading the files to. How, using the Linux FTP command, can I download every file, creating the directories needed for them in the process?

我需要从FTP服务器下载所有内容到托管在不同的服务器上。我只有shell访问我正在下载文件的服务器。如何使用Linux FTP命令下载每个文件,在此过程中创建所需的目录?

3 个解决方案

#1


54  

Use wget in this manner (m for mirroring):

以这种方式使用wget(m用于镜像):

wget -m ftp://username:password@ip.of.old.host

If your username or password contains special characters, you may need to use the format:

如果您的用户名或密码包含特殊字符,则可能需要使用以下格式:

wget -m --user=username --password=password ftp://ip.of.old.host

Alternatively, I found this guide which shows you how to do it using ncftp in Debian. You will require root access to the new server if ncftp is not installed already.

或者,我发现本指南向您展示如何在Debian中使用ncftp进行操作。如果尚未安装ncftp,则需要root访问新服务器。

In short:

简而言之:

sudo apt-get install ncftp
ncftpget –T –R –v –u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data

#2


1  

Some FTP servers allow to download whole directories by suffixing their name with .tar or .tgz. The server then creates an archive of that directory.

某些FTP服务器允许通过使用.tar或.tgz后缀其名称来下载整个目录。然后,服务器创建该目录的存档。

#3


1  

Another way is to use ftp. Here's an example shell script using ftp:

另一种方法是使用ftp。这是使用ftp的示例shell脚本:

#! /bin/bash

ftp -n << 'EOF'
open ftp.your_ftp_host.com
quote USER your_username_here
quote PASS your_password_here
cd gets
prompt no
mget * .
bye
EOF

#1


54  

Use wget in this manner (m for mirroring):

以这种方式使用wget(m用于镜像):

wget -m ftp://username:password@ip.of.old.host

If your username or password contains special characters, you may need to use the format:

如果您的用户名或密码包含特殊字符,则可能需要使用以下格式:

wget -m --user=username --password=password ftp://ip.of.old.host

Alternatively, I found this guide which shows you how to do it using ncftp in Debian. You will require root access to the new server if ncftp is not installed already.

或者,我发现本指南向您展示如何在Debian中使用ncftp进行操作。如果尚未安装ncftp,则需要root访问新服务器。

In short:

简而言之:

sudo apt-get install ncftp
ncftpget –T –R –v –u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data

#2


1  

Some FTP servers allow to download whole directories by suffixing their name with .tar or .tgz. The server then creates an archive of that directory.

某些FTP服务器允许通过使用.tar或.tgz后缀其名称来下载整个目录。然后,服务器创建该目录的存档。

#3


1  

Another way is to use ftp. Here's an example shell script using ftp:

另一种方法是使用ftp。这是使用ftp的示例shell脚本:

#! /bin/bash

ftp -n << 'EOF'
open ftp.your_ftp_host.com
quote USER your_username_here
quote PASS your_password_here
cd gets
prompt no
mget * .
bye
EOF