SVN

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

Android Projects in SVN – What Files to Ignore?

Setting up your svn:ignore property when you first open a new repository is a good way of making sure you keep unnecessary files from being revisioned. There are basically two entries that you need to make to your svn:ignore list:

  • bin
  • gen

The /gen folder contains files generated by the Android framework, such as the R.java file, and the /bin folder contains files generated when compiling and running the application from within Eclipse.

The .classpath and .project files, as well as the .settings folder are generated by Eclipse, and are best kept in your repository as it makes importing your project into Eclipse much easier, not to mention these files rarely change.