Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar 1" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /usr/share/wordpress/wp-includes/functions.php on line 4161 Tech Notes » Blog Archive » Rsync Over FTP, on a Mac or BSD Client

Rsync Over FTP, on a Mac or BSD Client

howto, Uncategorized 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 remote server is pulled to q local folder: changes changed, new files created, removed files removed. This is that kind of thing that should be easier, but it’s mixing an old technology (rsync) with a very, very old technology (FTP).

This is how to do it using mount_ftp and rsync.

The general idea is to use the mount_ftp almost like FUSE-mounting a remote resource, then using rsync on that mounted filesystem. If we wrap it around mktemp to work relatively portably in a temp folder, we’d have 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; no output, but the return code matches errno.h values
sudo mount_ftp -o rw ${TEMPFILE} ; echo $?

# sadly, despite best efforts (and "-o rw"), this is only a read-only, so only good
# for syncing FTP content out to the local system

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

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

Leave a Reply

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