Dumping a repository is sometime necessary, for example when you want to transfer it from one place to the other, say from Google Code to Sourceforge. The dump is normally created using svnadmin. However if you ever try to dump a remote repository, you’ll find out that it can’t be done:
svnadmin dump http://projectname.googlecode.com/svn > repodump
svnadmin: 'http://projectname.googlecode.com/svn' is an URL when it should be a path
One way around that is to use svnsync. This utility allows you to synchronize a local depository with a remote one. So the technique here is to create an empty repository, synchronize it with the remote one, and, finally, dump the local repository.
Here are some notes on how to do that:
1. Create a local repository
svnadmin create c:/repository
2. Add a “pre-revprop-change” hook to the local repository.
echo > c:\repository\hooks\pre-revprop-change.cmd
This is done by opening the “hooks” folder of the repository and adding a blank “pre-revprop-change.cmd” file into it. This will enable revision property change, which is necessary for synchronization.
On Linux and Mac, please follow the instructions in this comment.
3. Synchronize your new repository with the remote one:
svnsync init file:///c:/repository https://example.googlecode.com/svn
svnsync sync file:///c:/repository
Note: if you get this error: “Cannot initialize a repository with content in it“, it means that you’ve made some changes to the repository. In which case, the best thing to do is to just delete it and start over. The repository must be completely empty for the synchronization to work.
4. Finally, once the synchronization is done, simply dump your local repository:
svnadmin dump c:/repository > repodump
If everything went well, repodump should now contain the exact content of the remote repository.
Everything in one batch script
The batch script below allows to do all that in just one script. Simply replace REPO_PATH and REPO_PATH_NUX by the path to your repository and REPO_URL by the repository URL.
SET REPO_PATH=c:\your\local\repository
SET REPO_PATH_NUX=file:///c:/your/local/repository
SET REPO_URL=https://example.com/remote/repository
REM Uncomment the line below if the repository folder already exists
REM rmdir %REPO_PATH% /s/q
mkdir %REPO_PATH%
svnadmin create %REPO_PATH%
echo > %REPO_PATH%\hooks\pre-revprop-change.cmd
svnsync init %REPO_PATH_NUX% %REPO_URL%
svnsync sync %REPO_PATH_NUX%