Backing Up & Restoring a Remote SVN Repository

If you’re hosting your Subversion repository remotely, either through a web host or through one of many Subversion hosting services, you probably won’t have direct access to the server to be able to run shell commands on it. This can create a challenge when it comes to backing up and restoring your SVN repositories remotely.

Trying to achieve this using the svnadmin command will not work:

svnadmin load http://project.hosting/svn/repo < dump
svnadmin: 'http://project.hosting/svn/repo' is an URL when it should be a path

There is however a way of doing this remotely.

What You Need

You’re going to need a a tool called svnrdump. As described by Apache, “svnrdump replicates the functionality of svnadmin dump and svnadmin load, but works on remote repositories, instead of needing administrator (local filesystem) access to the source or target repository.”

The easiest way to get svnrdump is by downloading and installing the SVN client utility, TortoiseSVN and making sure to install the “Command Line Client Tools” in the installer options. You can then find svnrdump inside the bin folder where TortoiseSVN was installed.

Backing Up Your Repository Remotely

We’re now going to generate a .dump file which contains the entire history of revisions for our repository. To make a complete backup run the following command:

svnrdump dump [SOURCE_URL] > [DUMP_DESTINATION]

For example:

svnrdump dump svn://myrepohost.com:port/repos/myproject > C:\myrepobackup.dump

Note that this command requires your target server to be running SVN 1.4 or newer. For more information about the dump command as well as additional parameters please see the documentation.

Restoring Your Repository Remotely

Now that we have our .dump file, we can use it to restore our repository. To restore your repository run the following command:

svnrdump load [DESTINATION_URL] < [SOURCE_DUMP]

For example:

svnrdump load svn://myrepohost.com:port/repos/newproject < C:\myrepobackup.dump

Note that this command requires your target server to be running SVN 1.7 or newer. For more information about the load command as well as additional parameters please see the documentation.

Here’s a windows batch file that I use to make one click backups, it creates a file called SVN_YYMMDD.dmp in the same directory as the batch file:

for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set y=%%k
for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k%%i%%j
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set t=%%i%%j
set "outFilename=%~dp0SVN_%d%.dmp"

cd "C:\Program Files\TortoiseSVN\bin"
svnrdump dump svn://yoursvnserver:port > %outFilename%
PAUSE

Categorized: SVN

4 Comments

  1. nitish · July 17, 2015 Reply

    thats what im seaching
    thank you so much

  2. walter gunter · August 4, 2015 Reply

    excellent instructions. I have been looking all over for this breakdown.

  3. bernie · December 13, 2016 Reply

    How to load incremental for svn from specific revision?

  4. Ilmari Kontulainen · February 6, 2017 Reply

    Hi,

    Thank you greatly for the instructions. We use this article as a basis for our user guide regarding the same topic.

Leave a Reply to Ilmari Kontulainen