Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy all files via FTP in rsync

Tags:

linux

rsync

ftp

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

like image 591
Mahakaal Avatar asked May 13 '11 03:05

Mahakaal


2 Answers

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.

like image 117
sarnold Avatar answered Oct 10 '22 16:10

sarnold


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.

like image 35
Ryan C. Thompson Avatar answered Oct 10 '22 16:10

Ryan C. Thompson