This should be an unusual blog. I’m attempting to combine a belated shoutout for nor’s collaborative porn project, OpenSauce with a howto guide to making rsync work on windows. Lets see how it that works out.
The OpenSauce Project
Nor's radicalx project has previously investigated the connections between activist and "kinky" cultures. Now she is interested in exploring the connections between the free culture/free software movement and sexuality in cyberspace. Using a simple wiki, the project investigates what collaborative pornography might look like. Rather than a broadcast, centred, patriarchal model of sexuality, where some distant professional decides what are the rules of the game, OpenSauce uses the technology of the "open source" movement to enable the internet community to create a collaborative fantasy together.
Like so many projects these days, its made out of Drupal. I helped Nor develop a little script for her exhibit at the Brookes Degree Show to suck the node revisions out of drupal and make a customised browsing interface that lets you investigate the diffs between the revisions. Now the wireless network at Brookes was until this week non-existent and in general may well be unreliable. So the approach that we decided to take was to make a script that generated flat html files. Those files could then be rsync-ed to the exhibition server as and when the network was functional. Unfortunately, we had to make the rsyncing on the brain dead crock of shite OS that is windows. *shudder*
So, How do you make windows do a regular rsync?
OK, let's outline the technical challenge. As we’ve said, we are on an unreliable network. We want to rsync our html files regularly (say every 10 minutes). So, first of all we need to make windows 7 run an rsync. Then we need to find something that lets us run regular jobs; the scheduler doesn't cut it — once a day is not regular enough. Hah, and we need to run rsync on a nonstandard port. Just to make things interesting.
First Challenge: rsync on windows 7
Thanks to the lovely rsync.net who were kind enough to post about it, I found cwRsync which is the cygwin version of rsync. Good enough? Hmmmmmm... well I did swear a lot, but after I remembered how to set the $HOME variable under DOS. Here we do the making a ssh key thang, but in a win7 stylee, props to the rsync.net crew for this.
- First download the installer from sourceforge. Run it and let it install to the default place: C:\Program Files\cwRsync . That's important apparently.
Now to generate our key.
cd "c:\program files\cwrsync\bin" set HOME=/cygdrive/c/ ssh-keygen.exe -t rsa -N ''Notice the /cygdrive/c/ bit. rsync.net's tute doen't mention that. It's important though. I’ve used different slashes from yer usual windows ones and prepended /cygdrive/ to the filepath I am using as my home directory.
- Next, you'll be asked to choose a filename, and choose a passphrase. Press enter three times ;-)
Now we need to push our key on to the server, so we'll be able to log on without a password. We are running ssh on a nonstandard port, 44 in this case.
> rsync.exe -ave 'ssh.exe -p44' "/cygdrive/c/.ssh/id_rsa.pub" email@example.com:~/public-key" > ssh.exe -p44 firstname.lastname@example.org $ cat public-key >> .ssh/authorized_keys $ exit >
OK, now we are ready to make a DOS batch file that will let us sync shit up. Fire up notepad (!) and do something like this.
rsync.exe -qze 'ssh.exe -p44' email@example.com:~/public_html /cygdrive/c/html
Now we have a batch file that we can run whenever. Now we need something less brain dead than the windows scheduler to let us run our batch script regularly. Any windows geeks out there? I would love to hear if there is a native way to make this happen. Anyhow, I found a rather nice tool called zCron. Its a sort of graphical crontab. Download and install, then do this.
- OPen up the UI. It might have gone to your tray. A rightclick and show should bring it up.
- Create new crontab, give it a label and use the ".." button to point to your sync batch file.
- Click Batch and choose to run hidden, close window after run and "Windows Shell". OK that.
- Go to the scheduler tab, click scheduler and choose every 10 minutes (or whatever). Check "Weekday", and click "Every Day".
- In the run as tab, set your usename and password. Click Save and you're ready to rock.