Linux 从 FTP 服务器下载所有文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3003135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 20:06:59  来源:igfitidea点击:

Downloading all files from an FTP Server

linuxftpdebian

提问by Navarr

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 服务器下载到托管在不同服务器上。我只能访问我将文件下载到的服务器。如何使用 Linux FTP 命令下载每个文件,并在此过程中创建它们所需的目录?

采纳答案by Emil Vikstr?m

Use wgetin this manner (m for mirroring):

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

wget -m ftp://username:[email protected]

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 guidewhich 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

回答by mouviciel

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 来下载整个目录。然后服务器创建该目录的存档。

回答by mgoldwasser

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