FTP module for Node.js that can sync files?

I am looking for a module for Node.js - preferably available through npm that can sync files with an FTP server. The ftp module has all the basic functions, but writing a full blown sync system on top of it seems like a lot of work.

I'm the author of jsftp. It should be easy to sync through it simply walking through the directories you want to upload. Jsftp can handle parallel passive requests (internally they are still sequential, but you don't have to worry about it), so you could just use sequential ftp.put calls and it should work without much scripting effort on your side.

Even better and more idiomatic in node would be to use the yet to be documented ftp.getPutSocket method, which allows you to get the raw PASV socket and just push into it (using streams, for example). For a particular example of this case, you can look at how vfs-ftp does it.

Feel free to contact me if you need more help with implementing the syncing.

Take a look at node-ftpsync and grunt-ftpsync

It utilizes Sergi's jsftp library to intelligent sync files to a remote server.

Note: Currently, everything needed for push support is implemented except timestamp based update comparisons. For now updates are determined by comparing file sizes alone.

node-ftpsync provides both CLI support and a programming API. The preferred solution is to install it globally and run it in a directory containing a config.json. Alternately, it is also implemented as a lib that can be easily configured, extended, and launched within code.

grunt-ftpsync works the same way except configuration and running the application is done through grunt. It can even outputs fancy colorized logs.

Disclaimer: I am the author of node-ftpsync and grunt-ftpsync

I did some research by searching npm, github and the web and couldn't come across any good looking solution to syncing.

I would simply start by writing my own (simple) synchronization lib by using some good ftp library. Personally I find jsftp to be the most appealing (http://sergi.github.com/jsftp/). Just combine jsftp with some filesystem walking - especially if you are fine with simple one-way syncing, this shouldn't be impossible to do.

Some ideas for implementing (one-way sync from local filesystem to ftp):

  • Open connection to the ftp server
  • Walk through local filesystem with fs.readdir
  • Get stats from the corresponding ftp file and upload if local version is newer (Ftp.ls and Ftp.put if using jsftp)

Alternatively, ask yourself do you really need to perform the sync with node.js? For instance if you can run Python scripts in your system, you could simply use ftpsync2d, a bidirectional sync tool with ftp support (http://code.google.com/p/ftpsync2d/).