Saturday, October 8, 2011

SVN Tip: Making a local copy of a SVN Repository (with history) on Windows

This evening I needed a way of making a copy of some externally hosted SVN repository, complete with history before it went down. After searching for a while and only turning up results with how to do it on Linux, I finally found the solution.

Thanks for the tutorial "Massimo Iacolare". Works like a treat here.

The text below is COPIED DIRECTLY from the tutorial in the link above, and IS NOT MY OWN TEXT. (But, just copying it here so that there's another copy out there for the world to refer to...)

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 --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


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

--  See the original tutorial on:

No comments:

Post a Comment