cwRsync – Grey Panthers Savannah https://grey-panther.net Just another WordPress site Wed, 21 Feb 2007 09:06:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 206299117 Using rsync on Windows https://grey-panther.net/2007/02/using-rsync-on-windows.html https://grey-panther.net/2007/02/using-rsync-on-windows.html#comments Wed, 21 Feb 2007 09:06:00 +0000 https://grey-panther.net/?p=899 First of all, what is rsync?

It is a protocol and an implementation of it for bandwidth efficient file synchronization. In a nutshell it can synchronize two directories (one local and one remote) while making sure that only the minimal amount of data is transferred. It accomplishes this by breaking the files up in blocks and only transferring the blocks which are necessary (so if you appended – or preppended, or inserted in the midle – something to a file, only the new data will be transferred, not the whole file). You can find a more detailed description here, or you can read the rsync technical report and the original PhD thesis.

The problem (as with most great tools) is that there is no version for Windows. There are two Windows ports that I know of: DeltaCopy and cwRsync. They both are packages which bundle the Cygwin version of rsync with the needed DLLs (cygwin1.dll, and so on). Cygwin is an emulation layer for Windows which allows to create a Linux-e environment and run / compile many of the tools available for Linux without modification.

There are two things you should watch out for:

The first and most important: different versions of cygwin1.dll do not play well together. The symptoms include the rsync client entering in an infinite loop and consuming 100% of your processor and mysterious error messages which talk about shared section mismatches. If you encounter one of these, do a system wide search for cygwin1.dll and make sure that only one exists. Tricks like putting a cygwin1.dll with a different version in the directory of the executable and creating the .local file don’t work either because different instances of the loaded DLL need to communicate between eachother and this is impossible if there is a version mismatch. As of my limited experience the cygwin1.dll included with the cwRsync distribution worked fine with other Cygwin programs, but there might be some hidden incompatibilities.

The second gotcha is that you have to refer to your directories in the form of /cygdrive//path/with/slashes. So for example E:stufftosync becomes /cygdrive/e/stuff/to/sync. Also I found that the most reliable way to run the rsync client is to use the current directory as source / target (eg. .). In this situation the pushd / popd batch commands come in handy (and remember, opposed to cd, they can also change the current drive).

Also, I use rsyncd / rsync in a client-server (also referred to as daemon) mode, not over SSH (because I use it inside a trusted network). In this case you must specify two colons when writing the network source, like this: 192.168.0.1::tosync.

For a more detailed tutorial check out this tutorial on rsync which also applies to cwRsync almost entirely with the caveats mentioned earlier.

And a final note about the modus operandi of rsync: while the synchronization is in progress a temporary file is created in the same directory. After the synchronization of that given file is done, the old file is overwritten with the new version. I mention this because it may be the case that you wish to synchronize things which are currently locked and I don’t really know how well rsync handles this situation (given that under Linux, its original platform, it is possible to delete locked files as long as you have the rights to do so, without affecting programs which have a handle already open to it). So be cautious!

Update: if you are using Windows Server 2008 and you are getting error messages when trying to use rsync (something along the lines of failed to create shared section), make sure that you’ve updated to the latest version of it, which currently is 2.1.5. Also, it may refuse to install on Windows Server 2008. As a workaround you could install it on an older version of Windows (up to Server 2003) and copy over the files.

]]>
https://grey-panther.net/2007/02/using-rsync-on-windows.html/feed 11 899