如何在rsync中通过FTP复制所有文件

发布于 2024-11-06 12:33:31 字数 166 浏览 2 评论 0原文

我有一些主机的在线帐户,它为我提供了带有用户名和密码的 FTP 帐户。

我有另一个公司,它给了我 FTP 和 rsync 。

现在我想使用 rync 将所有文件从旧 FTP 传输到新 FTP。

现在是否可以通过 rsync 来完成,因为我不想先在计算机上复制然后再次上传

I have online account with some Host which give me FTP account with username and password .

i have another with copany which gave me FTP and rsync .

Now i want to transfer all my files from old FTP to NEW FTP with rync.

Now is it possible to do it via rsync only because i don't want to first copy on computer and then upload again

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

才能让你更想念 2024-11-13 12:33:31

让我们仅使用 FTP src 来调用机器。

让我们使用 FTP 和 SSH dst 调用机器。

ssh dst
cd destination-direction
wget --mirror --ftp-user=username --ftp-password=password\
     --no-host-directories ftp://src/pathname/

请注意,在命令行上使用 --ftp-password 运行 wget 会将密码泄露给系统上的其他任何人。 (以及以明文方式通过线路传输,但您知道这一点。)

如果您无权访问 wget,那么他们可能有 ncftp 或 <已安装 code>lftp 或 ftp。我只是碰巧知道 wget 最好。 :)

编辑 要使用ftp,您需要执行类似以下操作:

ftp src
user username
pass password
bin
cd /pathname
ls

此时,记下远程系统上的所有目录。使用 !mkdir 创建每一个。然后更改为本地和远程目录:

lcd <dirname>
cd <dirname>
ls

对所有目录重复此操作。使用mget *获取所有文件。

如果这看起来很糟糕,那是因为事实确实如此。 FTP 不是为此而设计的,如果您的新主机没有更好的工具(请务必查找 ncftplftp 以及类似 ftpmirror 的东西),然后要么自己编译更好的工具,要么擅长围绕不好的工具编写脚本。 :)

或者,如果您可以在 src 上获得 shell,那也会有很大帮助。 FTP 并不适合传输数千个文件。

无论如何,这可以避免在本地系统中发生跳动,这应该会显着提高吞吐量。

Lets call the machine with only FTP src.

Lets call the machine with FTP and SSH dst.

ssh dst
cd destination-direction
wget --mirror --ftp-user=username --ftp-password=password\
     --no-host-directories ftp://src/pathname/

Note that running wget with --ftp-password on the command line will give away the password to anyone else on the system. (As well as transferring it over the wire in the clear, but you knew that.)

If you don't have access to wget, then they might have ncftp or lftp or ftp installed. I just happen to know wget the best. :)

Edit To use ftp, you'll need to do something more like:

ftp src
user username
pass password
bin
cd /pathname
ls

At this point, note all the directories on the remote system. Create each one with !mkdir. Then change into the directory both locally and remotely:

lcd <dirname>
cd <dirname>
ls

Repeat for all the directories. Use mget * to get all the files.

If this looks awful, it is because it is. FTP wasn't designed for this, and if your new host doesn't have better tools (be sure to look for ncftp and lftp and maybe something like ftpmirror), then either compile better tools yourself or get good at writing scripts around the bad tools. :)

Or if you could get a shell on src, that'd help immensely too. FTP is just not intended for transferring thousands of files.

Anyway, this avoids bouncing through your local system, which ought to help throughput significantly.

贩梦商人 2024-11-13 12:33:31

总有值得信赖的 FUSE 文件系统,CurlFtpFSSSHFS。使用适当的文件系统安装每个服务器,并使用标准实用程序进行复制。可能不是最快的方法,但很可能是最省力的方法。

There's always the trusty FUSE filesystems, CurlFtpFS and SSHFS. Mount each server with the appropriate filesystem and copy across using standard utilities. Probably not the fastest way to do it, but quite possibly the least labor-intensive.

南城旧梦 2024-11-13 12:33:31

我一直在寻找一种简单的解决方案,通过 FTP 将远程文件夹同步到本地文件夹,同时仅替换新文件。我遇到了一个基于 sarnold 的小 wget 脚本答案,我认为对其他人也可能有帮助,所以这里是:

#!/bin/bash    
HOST="1.2.3.4"
USER="username"
PASS="password"
LDIR="/path/to/local/dir"    # can be empty
RDIR="/path/to/remote/dir"   # can be empty

cd $LDIR && \                # only start if the cd was successful
wget \
  --continue \               # resume on files that have already been partially transmitted
  --mirror \                 # --recursive --level=inf --timestamping --no-remove-listing
  --no-host-directories \    # don't create 'ftp://src/' folder structure for synced files
  --ftp-user=$USER \
  --ftp-password=$PASS \
    ftp://$HOST/$RDIR

I was looking for a simple solution to sync a remote folder to a local folder via FTP while only replacing new files. I got stuck with a little wget script based on sarnold's answer that I thought might be helpful to others, too, so here it is:

#!/bin/bash    
HOST="1.2.3.4"
USER="username"
PASS="password"
LDIR="/path/to/local/dir"    # can be empty
RDIR="/path/to/remote/dir"   # can be empty

cd $LDIR && \                # only start if the cd was successful
wget \
  --continue \               # resume on files that have already been partially transmitted
  --mirror \                 # --recursive --level=inf --timestamping --no-remove-listing
  --no-host-directories \    # don't create 'ftp://src/' folder structure for synced files
  --ftp-user=$USER \
  --ftp-password=$PASS \
    ftp://$HOST/$RDIR
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文