Kember.net

Rsync on Windows for Strongspace

Posted 13 August 2006, 11:48. (Filed under: by Andrew)

David Barrett has posted a fantastic tutorial about using rsync on Windows to backup to Strongspace.

It got me 90% of the way there, but there are a couple of unanswered questions. So here are the steps I’ve taken to do this. I’ve not included any screenshots, because David’s got that pretty much covered.

The idea is to do this without a full install of Cygwin. I think Cygwin’s wonderful, and I use it all the time, but this rsync thing needs to work with the smallest set of applications, using utilities (and a shell) that everyone’s got. In fact, I’ve found that having Cygwin was a problem for me, as it was difficult to tell which versions of the cwRsync modules were being used – the ones that came with it, or the Cygwin ones. The default location for the .ssh folder is based on the Cygwin home directory, which on my PC is c:\cygwin\home\Kember because I’ve got a full-time cygwin installation. David’s tutorial says that the default location if you’ve got no Cygwin installation is in in your Windows home directory, e.g. C:\Documents and Settings\Kember.

Right. Here we go. Get your Windows XP PC and phone Microsoft to check you’ve got a valid licence, then ask them if they can sell you any more great software (kidding).

Install the software and test it

  1. Install the latest stable version of cwRsync to c:\cwRsync, instead of the default which is in Program Files. cwRsync is a collection of open source tools put together in a way that makes rsync work on Windows.
  2. You need to modify your PATH environment variable. Add C:\cwRsync\bin; to it. Make sure it’s got a semicolon between each item – look at the other items in the PATH statement if you need a hint.
  3. Add a user environment variable called RSYNC_RSH with the value ssh.exe
  4. Now you need to test this.
    1. Start a command prompt (Start > Run; type cmd; press enter
    2. Enter the following: c:
    3. cd c:\
    4. rsync -avz --delete "cwRsync/doc" username@subdomain.strongspace.com:testrsync This is all on one line.
    5. Warning! If you already have a directory called testrsync/cwRsync in the Home directory of your Strongspace account, then this command will delete the contents of it.(Warning copied from David!)
    6. Remember to replace username and subdomain with the right bits from your Strongspace account
    7. Windows firewall may ask you if you want to block this application. Check that the app to be unblocked is the correct one, then unblock it.
    8. As this is the first time you’ve connected to Strongspace with this ssh thingy, it’ll prompt you about caching the key and continuing the connection. Enter yes
    9. When prompted, enter your Strongspace password
    10. Watch the files upload. Once it finishes, check your Strongspace account, to make sure they’re all present and correct.

Making the SSH keys
This is so you don’t need to put in your password each time rsync connects to Strongspace.

  1. Open a new command prompt
  2. Make sure you’re in your home directory (that’s where it should be by default)
  3. Enter the following: ssh-keygen -P "" -t dsa
  4. It will ask you where you want to put the files, and what you want to call them. Accept the default location, but remember where it is!
  5. Change directory into the default location, and into the .ssh directory
  6. copy id_dsa.pub authorized_keys
  7. cd ..
  8. rsync -avz ".ssh/authorized_keys" username@subdomain.strongspace.com:.ssh/authorized_keys
  9. del .ssh\authorized_keys
  10. Now you need to test this.
    1. Start a command prompt (Start > Run; type cmd; press enter
    2. Enter the following: c:
    3. cd c:\
    4. rsync -avz --delete "cwRsync/doc" username@subdomain.strongspace.com:testrsync
    5. Watch the files upload. Once it finishes, check your Strongspace account, to make sure they’re all present and correct.

This should not prompt you for your password. If it does, then we’ve done something wrong.

* * *