svnsync with PuTTY on Windows

Objective:

Maintain a copy of my local Subversion repository on my hosting server ready for deployment of my application using Capistrano.

Steps:

  1. Create remote svn repository
  2. Set up svn+ssh using PuTTY on Windows
    1. Download plink.exe and puttygen.exe to you local machine.
    2. run puttygen and generate a public/private key pair
      Don't set a pass phrase and svn will not prompt you for it later.
    3. Save the private key to keyfile.ppk on your local hard disk.
    4. On the remote host open a file ~/.ssh/authorized_keys and paste in the public key from puttygen.
      Make sure the string fits on a single continuous line.
    5. In the file abov, pre-pend command="svnserve -t" to the start of the public key.
      This forces the svnserve process to run when ever someone connects using this key pair. Having no passphrase on the key pair isn't great for security but at least you are restricting access to just svn and not the whole shell.
    6. On the local Windows machine, edit %Application Data%\Subversion\config, under the [tunnels] section add
      [tunnels]
      ssh =plink -i \path\to\keyfile.ppk
      (use back slashes / despite it being on Windows)
    7. Test using svn info svn+ssh://username@host.com/home/username/svn-repos/application
  3. Set up two environment variables to save on the typing
    set torepos=svn+ssh://username@host.com/home/username/svn-repos/application
    set fromrepos=file:///s:/svn-repos
  4. Initialise the synchronisation set up
    svnsync init %torepos% %fromrepos%
  5. Check the synchronisation parameters have been correctly set on the remote repository
    svn proplist --revprop -r 0 %to%
    svn propget svn:sync-from-url --revprop -r 0 %torepos%
  6. Now do the sync
    svnsync sync %torepos%
  7. Sit back and wait, or in my case, go to bed.

Sources of inspiration: