spSync - Free command line file and folder synchronization

Download spSync-1.5.zip (1.5MB).

This is a command-line program for synchronizing folders - between two folders across a network share, your PC and an ftp site, even between two ftp sites!

Really important README to avoid being sad or mildly frustrated

This is a synchronization program. Once two folders are synchronized, re-running the program wll keep them synchronized. If you delete content on one side, it will delete the content on the other side [*]. Do not think "Oops, this document is wrong. I'll delete it and next time I synchronize I'll get the previous version back". You won't. Your deletion will be synchronized and you will also delete the document on the other side. This could make you sad. Instead, you should manually copy the document from the other side.

[*] Okay, it's not quite that bad. Whenever a file or folder would get replaced or deleted, they actually get renamed to something like file.spSync.lhs-deleted (in this case, meaning this file was 'deleted' because the file on the left-hand side was deleted). Renaming the file will get it back again, so you'll probably get mildly frustrated rather than sad. Unless you specify the --nosafe option. Then it really will be deleted, and you really could get sad. Please don't do that. We want you to be happy, not sad.

Usage

spSync-1.5.exe --lhs <folder> --rhs <folder>

--lhsleft-hand side synchronization folder (typically the local side)
--rhsright-hand side synchronization folder (typically the remote side)

Examples of <folder>

"file:C:\Documents and Settings\name\My Documents"
file:\\myserver\myfolder
ftp:user/password@ftp.mysite.com/myfolder

Options

--a "name1" "name2" ...(or --ascii) List of file names to transfer as ascii in ftp. Otherwise, default is binary for ftp get; and heuristic test of file for ftp put. Names can include * wild-cards.
--log "log file" File to send log to, default is spSync.log.
--nosafe Specifying this option means that files or folders which would be overwritten or deleted are removed (instead of just renamed, the normal behaviour). You have been warned!
--x "name1" "name2" ...(or --exclude) List of file or folder names to exclude from the synchronization. Names can include * wild-cards.

Note that double-quotes can be omitted if the item does not contain spaces.

Understanding the output

spSync keeps two folders synchronized, and if that's enough for you to know than you need not read any further. But some people like to see what's being done and why, and so spSync outputs and logs it's progress. The output typically looks like this:

^ ---> o "file.doc" copy to "file:\\myserver\myfolder" [f211]

Here's how the output breaks down:

The arrow

^ ---> o

The actual arrow bit in the middle tells you in which direction the synchronization was being done (in this case, from the left-hand side to the right-hand side). The symbols on either end tells you the state of the file on that side. Here's what they mean:

^newer version
ounchanged
volder version
+created
xdeleted
_not existing

The text

"file.doc" copy to "file:\\myserver\myfolder"

This tells you exactly what's happening.

The code

[f211]

This is a short-hand description of how spSync perceived the situation. The f says it's looking at a file (d would mean directory). Then there are three numbers, representing the relative modification dates of the files - on the left-hand side, the last time they were synchronised, and on the right-hand side. In this case, the file on the right-hand side is unchanged since the last time the files were synchronized, whilst the file on the left-hand side is newer.


Some random details

  • spSync is designed to be safe - it won't actually delete or overwrite files, it will just rename them. It will give them hopefully meaningful new names (e.g. file.doc.spSync.lhs-newer, which tells you that the file.doc on the right-hand side was replaced because the one on the left-hand side was newer). Unless you specify the --nosafe option, which I wouldn't recommend unless you also have a backup of your files (in case you accidentally synchronize a deletion). See the really important README above.
  • To help spSync know what to do, it keeps track of the ages of files in a file called .spSync.lst, which it puts in every left-hand side folder it synchronizes. If you delete this file, spSync will still work, it will just have less information and so might behave differently. For instance, suppose you replace file.doc with an older version on the left-hand side, and re-synchronize. Normally, spSync will copy the older version to the right-hand side (because it knows from .spSync.lst that that's what you've done). Without the .spSync.lst file, all it knows is that file.doc is newer on the right-hand side, in which case it will copy that version to the left-hand side.
  • Any file or folder with .spSync in the name isn't synchronized.
  • When synchronizing to an ftp server, spSync will do it's best to set the modification time of the file on the ftp server. If it can't then it will set the modification time on the other side.
  • If one side has a file called "content", and the other side has a folder called "content", then the file will be renamed (or deleted if you specify the --nosafe option) and then folder synchronization will happen.
  • spSync uses a Win32 API for copying files whilst preserving file information. The API seems to occasionally forget to close file handles, so if you're about to start syncing many thousands of files, it may be better to copy all of the files first, and then start syncing.

The legal bit: This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

If you have any problems using this resource, or any suggestions on how it could be improved, please feel free to contact us.