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

时间:2022-09-01 11:31:33

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

我有一些主机的在线帐户,它给我FTP用户名和密码帐户。

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

我有另一个与copany给了我FTP和rsync。

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

现在我想通过rync将我的所有文件从旧FTP传输到新FTP。

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

现在可以通过rsync来实现它,因为我不想先在计算机上复制然后再上传

3 个解决方案

#1


14  

Lets call the machine with only FTP src.

让我们只用FTP src调用机器。

Lets call the machine with FTP and SSH dst.

让我们用FTP和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.)

请注意,在命令行上使用--ftp-password运行wget会将密码泄露给系统上的任何其他人。 (以及透明的电线传输,但你知道。)

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. :)

如果您无权访问wget,则可能安装了ncftp或lftp或ftp。我碰巧知道最好的。 :)

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

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

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:

此时,请记下远程系统上的所有目录。使用!mkdir创建每个。然后在本地和远程切换到目录:

lcd <dirname>
cd <dirname>
ls

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

重复所有目录。使用mget *获取所有文件。

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. :)

如果这看起来很糟糕,那是因为它。 FTP不是为此而设计的,如果你的新主机没有更好的工具(一定要查找ncftp和lftp以及ftpmirror之类的东西),那么要么自己编译更好的工具,要么擅长编写糟糕的脚本工具。 :)

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

或者,如果你可以在src上获得一个shell,那也非常有帮助。 FTP不是用于传输数千个文件。

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

无论如何,这可以避免在本地系统中弹跳,这应该有助于显着提高吞吐量。

#2


4  

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.

总是有可靠的FUSE文件系统,CurlFtpFS和SSHFS。使用适当的文件系统挂载每个服务器并使用标准实用程序进行复制。可能不是最快的方式,但可能是劳动密集程度最低的。

#3


1  

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:

我一直在寻找一个简单的解决方案,通过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

#1


14  

Lets call the machine with only FTP src.

让我们只用FTP src调用机器。

Lets call the machine with FTP and SSH dst.

让我们用FTP和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.)

请注意,在命令行上使用--ftp-password运行wget会将密码泄露给系统上的任何其他人。 (以及透明的电线传输,但你知道。)

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. :)

如果您无权访问wget,则可能安装了ncftp或lftp或ftp。我碰巧知道最好的。 :)

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

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

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:

此时,请记下远程系统上的所有目录。使用!mkdir创建每个。然后在本地和远程切换到目录:

lcd <dirname>
cd <dirname>
ls

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

重复所有目录。使用mget *获取所有文件。

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. :)

如果这看起来很糟糕,那是因为它。 FTP不是为此而设计的,如果你的新主机没有更好的工具(一定要查找ncftp和lftp以及ftpmirror之类的东西),那么要么自己编译更好的工具,要么擅长编写糟糕的脚本工具。 :)

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

或者,如果你可以在src上获得一个shell,那也非常有帮助。 FTP不是用于传输数千个文件。

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

无论如何,这可以避免在本地系统中弹跳,这应该有助于显着提高吞吐量。

#2


4  

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.

总是有可靠的FUSE文件系统,CurlFtpFS和SSHFS。使用适当的文件系统挂载每个服务器并使用标准实用程序进行复制。可能不是最快的方式,但可能是劳动密集程度最低的。

#3


1  

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:

我一直在寻找一个简单的解决方案,通过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