How to Backup and Mirror a Subversion Repository

On October 25, 2012, in Other Online Technology, by James Liu

Subversion has been used as my project version control system for years. Backup and restore subversion data will be a critical issue. Here are three ways to create a full mirror of a Subvrsion repository:

  • File Copy: treat the repository like any other filesystem and recursively copy it to the mirror location.
  • Dump/Load: Use svnadmin dump and svnadmin load.
  • Hotcopy: Use svnadmin hotcopy.

3 Ways to Backup Subversion Reviews

All these ways have their own advantage and disadvantage. In the following table, I will show the different between these 3 ways.

Different Between 3 Subversion Backup Ways
Method Server Downtime Replicates Configuration Speed
File Copy Yes Yes Quickest
Dump/Load No No Slowest
Hotcopy No Yes Quick

Backup subversion repository by copying

The only limitation of this backup way is the subversion system should be taken down when we are copying the repository to target. The command line of copy a subversion repository is

>cp -R path_of_repository path_of_destination

Backup subversion by svnadmin dump and load

Svnadmin dump is designed to create a portable repository dump. The resulting dumpfile can be loaded into a new Subversion repository – even if the new repository is using a different database backend, or even a different revision of Subverson. And you don’t need to take down the Subversion server when running the Svnadmin dump. This is the most common way to backup a Subversion repository. The command line looks like:

>svnadmin dump PATH_OF_REPOS > backup.dump
>svnadmin load PATH_OF_MIRROR < backup.dump //this is comment >

Backup subversion by svnadmin hotcopy

The svnadmin hotcopy doesn’t require any server downtime, completes in minutes, and replicates server configuration and hoot scripts. The command line is:

svnadmin hotcopy path_of_repository path_of_destination

Restore svn repository from hotcopy

Hotcopy is just like a copy. So the final backup folder is mirror repository which you can use directly. If you want to restore repository from hotcopy backup, you can easily copy the backup files back to your repository location.

SVN Trouble Shoot

When I am running svnadmin dump command, I get following error message:

svnadmin: Expected FS format between ‘1’ and ‘4’; found format ‘6’

It is because the svn and svnadmin version is too old. My current version is 1.6. I am going to the visualsvn.com and get the latest visual svn server. After I update the svn to 1.8, the problem is solved. You can using following command to get your svn and svnadmin version number.

>svn --version
>svnadmin --version

Another problem about the svnadmin dump is it doesn’t work with url. If you are running following command, you will get error:

svnadmin: ‘http://projectname.googlecode.com/svn’ is an URL when it should be a path

One solution for it is create a local svn repository and synchronize with the remote server.

 

8 Responses to “How to Backup and Mirror a Subversion Repository”

  1. Joseph Suarez says:

    Hola una consulta y en donde se guardan el backup que se hace, creo se hace donde se ejecute el comando no es así???

  2. Joseph Suarez says:

    Hello my query and En Donde backed ago That saved?

  3. Student says:

    Hi James, we have a huge subversion repository of 287 gb, that runs on apache.We need to migrate that to other server with different version of subversion.I have felt the svnadmin dump/load (even with gzip) takes lot of time.Would you suggest that i can take hotcopy, if so how much time would it take.Also, after the hotcopy is complete should i do an rsynch to new server and svnsynch? i basically want to avoid any downtime.Can you please recommend and provide the exact commands if possible.

  4. pardeep says:

    How to restore backup which has taken by below command
    svnadmin hotcopy /home/svn/repo1 /var/backup/repo1

    • James Liu says:

      The backup file is a mirror repository. If you want to restore your repository, please simply copy the backup repository back to your original repository.

Leave a Reply

WordPress主题

Free WordPress Theme