开发者

How to copy all files via FTP in 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 i开发者_如何学Cs it possible to do it via rsync only because i don't want to first copy on computer and then upload again


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.


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜