Rsync Over FTP, read-write, on a Mac or BSD Client

howto Add comments

Recently I was discussing with someone the need to simplify the sync of a folder into an FTP server. The goal is that at set intervals, any change in a local folder is pushed to a remote folder: changes changed, new files created, removed files removed. Similar to yesterday’s article, except this is a read-write access to the FTP server, allowing either direction of sync.

This is how to do it using curlftpfs and rsync.

The general idea is to use the curlftpfs almost like FUSE-mounting a remote resource, then using rsync on that mounted filesystem. Like yesterday, we use mktemp to work relatively portably in a temp folder.

The exult would be something like this:

  • local folder: ${HOME}/contrib
  • remote server:
  • remote folder: ./Scott/ABC
  • remote user: scott
  • remote pass: tiger
# create a temporary/random mountpoint
TEMPFILE=$(mktemp -d -t ftprsync)

# mount the remote space
sudo curlftpfs -o rw ${TEMPFILE}

# sync
rsync -avr --delete-after ${TEMPFILE}/* ${HOME}/contrib

#shut it down
sudo umount ${TEMPFILE}
rm -fr ${TEMPFILE}

Similar to the method used with mount_ftp, curlftpfs will use a URL-encoded user/pass. Additionally, curlftpfs will allow -o options to provide username and password.

The issue with this method is that obtaining the curlftpfs for MacOSX is problematic: it’s based on glib-2.0, and glib itself has a bit of a dependency to build. As well, it uses pkg-config which is still not a standard part of Apple Xcode CLI tools, but if you have glib-2.0 built, then you’ve already got pkg-config working (glib is heavily dependent)

In my own experience, curlftpfs is quite function, and plays very well with the automount config; the problem is that on very long distance connections, it seems to choke quite often during the sync. I would recommend using this method for low-lartency connections to legacy servers, and for longer-hauls, work on getting rsync able to connect directly without using FUSE to indirectly map to FTP.

…so the task right now is to build curlftpfs, or find a functioning binary.

Comments are closed.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in