Unison on windows tips
By gildor on Wednesday, October 20 2010, 11:23 - Permalink
The big advantage of Unison on Windows is that it allows quite easily to synchronize between Windows and Linux. For those who need to work on Windows with the same set of files as on Linux, this is a big plus. Other tools do it as well, but the 2-way sync of Unison is quite nice. When you need to compile a software on Linux and Windows, you can modify both side at the same time and (almost) don't have problems.
On Windows, the .unison and unison.log are located into your %HOMEPATH%, which the upper directory of the classic Documents folder. In the directory .unison, you will find the .prf files that describe your unison profiles. As usual, default.prf in this directory is the default profile.
The basic tips are:
- use fastcheck = true in your default.prf
- disable directory indexing
You can also disable virus live scan -- if you think it is safe!!!!
Using ssh under Windows is always a challenge. As a matter of fact, this tool doesn't match Windows context and it is not as integrated as in Linux/BSD.
There is Putty which can help you. It has a good support for remote shell but it is not very easy to setup with Unison. Putty and OpenSSH doesn't have precisely the same set of options and Unison relies on some not available in Putty. There is a script called ssh2plink.bat that can help you using Putty's plink as with Unison. I used it for a while, but this didn't give the expected throughput.
The best option is to use the ssh command provided by Cygwin. In this case you have at the same time good throughput and unison integration. I explain here how to configure you Cygwin's ssh to use a SSH key.
You can bypass the following steps, if you wish to use a password or if you have already setup your ssh to connect to the target computer.
Launch Cygwin's setup.exe and select openssh for installation.
To add a SSH key, launch the cygwin shell:
$ ssh-keygen -t rsa Generating public/private rsa key pair. [...]
Copy the file .ssh/id_rsa.pub to your target computer's .ssh/authorized_keys. You should be aware that the file format can be Windows EOL style (in this case use dos2unix to convert the file) and if you copy/paste from a dos box, some end of lines are added and you should remove them from the authorized_keys, to have a single line key.
Once, you have installed your ssh key into target computer, you should try to connect directly from the cygwin shell.
$ ssh XXX
Now, you can configure sshcmd = c:\cygwin\bin\ssh.exe to your default.prf.
Using Cygwin's ssh allow you to get ~2MB/s (or more) when you only get ~100KB/s using ssh2plink.bat.
If you have any other tips to improve Unison on Windows, I will be happy to test them and post it here.
Here is my unison.bat file used to sync my USB key with a target directory at the office (here c:\itinerant):
This unison.bat is called automatically when the key is inserted, via autorun.inf
The main problem of the script is that the key letter can always change if already assigned to another key ... But it's very light. PROG is on the key itself
set PROG=programs\unison\Unison-2.27.57 Text.exe
"%PROG%" -fastcheck true -auto -confirmbigdeletes %LETTER% "%LANDING%%WHERE%"