Using svnsync with VisualSVN

I’ve been using Subversion for quite some time, and yet I don’t consider myself an expert on it because for the most part it just does what I need without much effort on my part. Most of that is thanks to VisualSVN Server, which makes the whole process of running Subversion in a Windows environment so incredibly easy.

All of that is a bit of a long introduction to what’s going to be an incredibly short post about getting svnsync up and running with VisualSVN server. If you don’t know what svnsync is then you can probably guess from the name alone – it’s Subversion’s way of replicating a repository, something I’m doing to an offsite location as an additional layer of backup for my code.

There’s a range of good guides out there which cover configuring and using svnsync which should give you most of what you need to get up and running, but I’m going to add a couple of quick notes from my experiences below:

1. Configuring the pre-revprop-change-hook in VisualSVN in the destination repositorythe guide I mentioned earlier gives a Unix specific example, and I found a lot of other people talking about this hook in the context of svnsync without anyone mentioning the simple fact that this hook needs to exist, but it can be blank. From VisualSVN Manager, right click on your repo and select “All Tasks \ Manage Hooks”. Select “Pre-revision property change hook” and edit that – enter a couple of blank lines then click ok. Done. The hook will now be listed in bold indicating it exists.

If you don’t have this configured, then you’ll get an error saying “svnsync: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent” when you try and sync or init.

2. Credentials – you should only need to enter your repository credentials when you perform the init of the mirrored repository. For some reason, my first sync failed until I provided credentials, but subsequent sync operations appear to be working fine.

And that’s it!

Posted on Monday, April 27, 2009 9:41 PM |

Like this? Share it!

  • # re: Using svnsync with VisualSVN
    Commented on 5/6/2009 2:42 PM

    Thanks. Most helpful!

  • # re: Using svnsync with VisualSVN
    Commented on 7/15/2009 6:52 AM

    tfs2svn would not work without this... much appreciated...

  • # re: Using svnsync with VisualSVN
    Commented on 7/17/2009 12:10 AM

    So, visualSVN and svnsync, how do i go about finding the path to the svnsync.exe file? the default location for visualSVN is in the programs files/visualSVN Server/bin directory, but it seems like the spaces in the words is a problem.
    my post commit file calls the following code to try to do the sync:

    svnsync initialize https://target/myproject/ https://source/myproject/ \
    --sync-username svnsync --sync-password syncpassword \
    --source-username sourceusername --source-password sourcepassword

    set SVNSYNC=/usr/bin/svnsync
    set TO=http://my.slave.machine/myproject/
    set SYNC_USER=svnsync
    set SYNC_PASS=syncpassword
    set SOURCE_USER=me
    set SOURCE_PASS=mypassword

    %SVNSYNC% --non-interactive sync %TO% \
    --sync-username %SYNC_USER% --sync-password %SYNC_PASS% \
    --source-username %SOURCE_USER% --source-password %SOURCE_PASS% & exit 0

    I think this will work, however, the svnsync variable above is /usr/bin/svnsync, but that location does not exist...can you help me figure out how to add the proper path to replace the above code?


  • # re: Using svnsync with VisualSVN
    Commented on 9/17/2009 10:16 PM

    Thanks very much.. this helped me a lot.

  • # re: Using svnsync with VisualSVN
    Commented on 2/10/2010 8:44 PM

    Thanks wouldn't have thought about this on myself.
    @dan (ok I know this post is long time ago, perhaps it helps someone else)
    It's standard windws behaviour, just take apostrophes cause of the blanks.
    At the startof your script you can put this two lines
    cd "C:\Program Files\VisualSVN Server\bin\"

    An then you can execute svnsync just as normal.

  • # re: Using svnsync with VisualSVN
    Commented on 3/22/2010 8:45 PM

    Great info on this post! Thanks for making it so clear!

  • # re: Using svnsync with VisualSVN
    Commented on 3/26/2010 6:11 PM

    One remembers that life seems to be not very cheap, however we need cash for different stuff and not every person earns enough cash. Therefore to receive fast home loans and college loan would be good solution.

Post a comment
Please add 4 and 2 and type the answer here:
Remember me?
Ensure the word in this box says 'orange':