Ftp transfer the rsync-way

Lasse A Karlsen picture Lasse A Karlsen · Dec 3, 2008 · Viewed 27.9k times · Source

I'm downloading a logfile quite often from a ftp-server (which I'm not in control over, btw), and it seems rather rediciolus to download the whole file every time.

So I'm looking for a program (linux-ish) or Perl module that in a way combines ftp and rsync, and only "updates" the file.

The logfile is constantly growing.

Anything like that around?

Answer

user78706 picture user78706 · Mar 9, 2009
Install curlftpfs (if on Windows, use cygwin)

# Create local mount path
mkdir -p /mnt/myftp

# Mount the destination ftp site using curlftpfs
curlftpfs -o allow_other ftp://myusername:[email protected] /mnt/myftp

# rsync inplace using append option
# use a long timeout value as the first long phase
# (the inplace comparison) takes a while
rsync -rzvvv --inplace --append --progress --stats --timeout=7200 /mnt/myftp/path/to/source/file.log /path/to/local/destination/file.log

# When you need to umount the ftp site
sudo umount myftp

# You can also mount from /etc/fstab by appending the following line
# curlftpfs#myusername:[email protected] /mnt/myftp fuse allow_other,rw,user,noauto 0 0

# References:
# http://linux.byexamples.com/archives/344/mounting-ftp-host-to-local-directory-on-top-of-fuse/
# http://lists.samba.org/archive/rsync/2007-May/017762.html