You're now viewing all of my posts relating to Rsync. Enjoy!
Rsync, Windows, OSX and more!
July 30, 2007
Brian recently wrote in with a few questions regarding rsync and how I used rsync in my daily life. I felt much obliged to respond to him but while typing my response, I realized something. I had recently been trying my damnedest to find good information on rsync I was always coming up short. Why? I was always coming up short because I was looking to use rsync in a non-standard fashion. Rather than the tried and true Unix->Unix sync, I was trying to synchronize Windows->Unix and it was becoming a huge pain in the ass. Well, Brian's question is a bit different but along the same lines.
Brian wanted to sync a Mac OSX box with a Windows box. Well, lucky for us that OSX is Unixie and already has access to rsync - so all that leaves us with is setting up rsync on Windows and getting the right glue in between! I have a quick disclaimer, however. I have not completely tested this method. I've only pulled together what I can to help out a reader having very similar troubles to what I had. That said, if you guys have any comments or suggestions I will definitely incorporate them here.
So, here we go. We're going to setup a Cygwin installation with both OpenSSH and Rsync. There is a version of Rsync out there for Windows called "cwRsync", but in my experience its been incredibly unstable and is a poor implementation. Things might have changed, but I would recommend staying away from it for serious production.
Setting up Cygwin and OpenSSH On Your Windows Box
First, you'll need to download and install cygwin. Its a fairly straightforward procedure. When you get to the package selection dialog be sure to select "OpenSSH" and "Rsync" for installation. You might find this article a little difficult to follow without them.
Once installed you'll need to do a little configuration to get the OpenSSH server up and running. At this point, you'll need administrative privileges to continue. For Vista or XP, just be sure to run "c:\cygwin\cygwin.bat" as Administrator and you'll be fine. Go ahead and run ssh-host-config and mimic the following answers (some of which may not show up if you're running <Windows 2003. If not stated, simply accept the defaults.
Should privilege separation be used? (yes/no) yes ... [only on >= Windows 2003] Should this script create a new local account 'sshd_server' which has the required privileges? (yes/no) yes ...
Now go ahead and start the SSH service manually by running "net start sshd". This may take a minute or two so give it time. You may also need to allow a "port exception" in Windows Firewall for Port 22. Just open up Windows Firewall in Control Panel and select "Change Settings". From there go to the Exceptions tab and select "Add Port...". You should now try SSH'ing into your Windows machine from a different machine, just to make sure that everything works at this point.
Running Rsync From a Remote Machine
At this point, most of the Windows configuration is done. You're going to want to begin working on your other machine now (in Brian's instance, his OSX machine) and start testing rsync. There's really no configuration to be immediately done for rsync to get it up and running since it will be using SSH as a tunnel to the Windows machine.
Go ahead and pick a small source directory to try to sync to your Windows machine. Also, make sure that there is a directory created on the Windows machine with a suitable user having access to it - here we'll call the user "rsync_access" and give him read/write permissions to "c:\rsync_repo". The source on the OSX machine will be "/rsync_repo" for simplicity.
rsync -e "ssh" -az /rsync_repo rsync_access@WINDOWSBOX:/cygdrive/c/rsync_repo
Tada! The files should be synced. One tweak I've noticed that helps Windows machines along is changing the "modify-window" option to be a little higher than usual by adding in --modify-window=15 to the command line mix.
If you're remote machine is Windows as well, you may need to install rsync via Cygwin the same way we did on the machine above. If you're on Linux, you may need to install it manually. "apt-get install rsync" will do the trick on most Debian distributions.
Fin!
At this point, everything is up and running and only needs some automation tweaks. I'll make an update to this article later with this content. Again, any comments or suggestions are warmly welcomed and will be incorporated into the article. I'm just trying to get this out there to help those in search of more rsync information.Until then, happy rsyncing!
References and Links
- cwRsync - not recommended
- Cygwin
- How to install OpenSSH sshd server and sftp server on a Windows 2000 or Windows XP [machine]
Permalink |
Add to delicious |
0 Comments
| Tagged: Rsync, Networking, SystemsAdministration, Computing
