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:
- Make a backup
- 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/
carodriguezb 3:21 am on March 13, 2010 Permalink |
Thanks, this information help me a lot.
Anuzer Koavne 3:32 pm on July 27, 2010 Permalink |
Thanks for information but i want to make files and folders mirror, not database. Can you help me about that?
Mike 11:23 pm on February 9, 2011 Permalink |
So far so good.. Thanks!
Michael Ebbage 12:56 pm on February 9, 2012 Permalink |
Thanks for this guide, it made the task so much easier – there doesn’t seem to be much information on the web covering this.
Sathish Kumar S 12:29 pm on February 15, 2012 Permalink |
Thanks, It Helped me for my requirement.
Michal 9:42 pm on June 26, 2012 Permalink |
In my case it was also needed to decomment [authz-db = authz] line. Thanks!
MrLeV 3:20 am on January 7, 2013 Permalink |
Thanks a lot for this step-by-step guide.
Note that if your remote svn provider requires a certificate on your side, you will have to provide it when asked (usually once per operation).