howto use svnsync to mirror a repository on windows 

I’m in the process of (hopefully) switching SVN hosting provider from eurosvn.com to xp-dev.com. To make that happen I first have to create a dump of my existing repository and it’s not something you can do on an online repo, svnadmin dump only works on local paths (which is a good thing ;-).
I’m going to post here the details of making a local readonly mirror repository. It’s useful for, at least, two reasons:
1. Make a backup
2. Make a dump 🙂
Ready? Ok, let’s start opening your command prompt:

I’m in the process of (hopefully) switching SVN hosting provider from eurosvn.com to xp-dev.com. To make that happen I first have to create a dump of my existing repository and it’s not something you can do on an online repo, svnadmin dump only works on local paths (which is a good thing ;-).

I’m going to post here the details of making a local readonly mirror repository. It’s useful for, at least, two reasons:

  1. Make a backup
  2. Make a dump 🙂

Ready? Ok, let’s start opening your command prompt:

1. Create a local repository

svnadmin create [YOUR NEW REPO PATH]
eg: svnadmin create c:\svnrepo\iacoware.

The root path must exists (c:\svnrepo). By default the repository is created as read-only

2. Enable writing on your new repo

Open file [PHYSICAL LOCAL REPO PATH\conf\svnserve.conf] and decomment line

[password-db = passwd] (line 20 in my file)

This tell to SVN which file stores user’s credentials.

3. Add a new user

Open file [PHYSICAL LOCAL REPO PATH\conf\passwd] and add a new user under the [users] group (mine svnsync_user = svnsync).

4. Give your new user read/write permissions

Open file [PHYSICAL LOCAL REPO PATH\conf\authz] and add:

[/]
svnsync_user = rw

5. Enable rev propchange (revision property change)

Look for the file “pre-revprop-change.tmpl” in [PHYSICAL LOCAL REPO PATH\hooks]. Make a copy and rename it to pre-revprop-change.bat. Open it and remove everything, be sure to leave only:

exit 0

6. Initialize the repository

svnsync init [LOCAL REPO PATH using file:// protocol] [REMOTE LOCAL PATH] --sync-username [USERNAME] --sync-password [PASSWORD]
eg: svnsync init file:///c:/svnrepo/iacoware http://your.svn.hosting.provider/your.repository --sync-username user_svnsync --sync-password svnsync

Getting the local repo path right could be tricky. Pay close attention to the number of slash. I used the file protocol but you can also use the svnserve protocol:

eg: svnsync init svn://iacoware ...
(obviously svnserve must be up and running, eg: svnserve -d -r c:\svnrepo)

7. Synchronize

svnsync sync [LOCAL REPO PATH]. Be aware, if your repo is big, it could take a loooot of time.
eg: svnsync sync file:///c:/svnrepo/iacoware

From now on if you want to synchronize your local repository you have to repeat only step no.7

HTH

Troubleshooting

If the synchronization process goes wrong (it happened to me) next time you’ll try to sync you’ll receive an error “failed to get lock on destination repos, currently held by…”. Run this command:

svn propdel svn:sync-lock --revprop -r 0 [LOCAL REPO PATH]

and life will be happy again

References

http://journal.paul.querna.org/articles/2006/09/14/using-svnsync/