Moving a Subversion repository to a new server

18 November 2009 | 0 comments | Tagged as: Subversion

There are many ways available to migrate a Subversion repository between servers using such tools as svnsync or svnadmin hotcopy.

However if you are migrating from a server with an old version of Subversion, you may not have these tools available.

The easiest method I have found to move a repository is simply dumping the repository to a file on one server, copying this file to the other server and then loading the file into the new repository. The commands show below are those I have used successfully before. First we will dump our existing repository into a dump file. We then ssh to our existing server and run the following substituting the path to our repository for the one below:

  $ svnadmin dump /var/svn/repos > svnrepos.svn_dump

Next secure copy the dumped file to the /var directory our new server:

  $ scp svnrepos.svn_dump username@machinename:/var

Now on you new server create a new empty subversion repository

 $ cd /var
 $ sudo mkdir svn
 $ sudo svnadmin create /var/svn/repos

Next create a new user to own the repository and change the ownership of the repository files:

 $ sudo adduser svn
 $ sudo chown -R svn:svn svn

In order for a user to be able to use this repository they now must be a member of the svn group. Modify an existing user and add them to the svn group:

 $ sudo usermod -a -G svn svnuser

Finally load your dump file into your new repository:

 $ svnadmin load /var/svn/repos < /var/svnrepos.svn_dump

If all goes well you should see output similar to the following:

------- Committed revision 7657 >>>
<<< Started new transaction, based on original revision 7658
     * editing path : example/releases/example-1.3/app/views/articles/show.rhtml ... done.
     * editing path : example/releases/example-1.3/app/views/layouts/articles.rhtml ... done.
     * editing path : example/releases/example-1.3/app/views/shared/_article.rhtml ... done.
------- Committed revision 7658 >>>
$ 

If you have ssh server installed on your server you can access the repository from your local machine as follows:

 $ svn co svn+ssh://svnuser@machinename/var/svn/repos

POST A COMMENT

Markdown available. Required *.

*

*

*

*