Saturday, June 14, 2008

Moving subversion repository from one server to another

Recently I had to move one subversion repository from one server to another and it is a very simple procedure.

The first step is to dump all the information of your current repository into a file. The following command will dump the repository named reponame (located at /svn_old_path) into the file named svndump.

sudo svnadmin dump /svn_old_path/reponame > svndump

Then, copy the svndump file to the new server. I am assuming that subversion is already installed on the new server, if not, this is the guide that I followed:

https://help.ubuntu.com/community/Subversion

I setup subversion to access via WebDAV protocol with SSL encryption (https).

On the new server, I will place all subversions repositories under /home/svn. First, we need to create a new repository:

cd /home/svn
sudo svnadmin create reponame

Now, use the load command to restore all information from the dump file into the new repository:

sudo svnadmin load reponame < svndump

Since I am using subversion access through https, I need to set the proper permissions on the files. In my case, the apache user is www-data and I created a group called subversion.

sudo chown www-data reponame -R
sudo chgrp subversion reponame -R

Finally, change the subversion configuration in Apache and add the new repository. In my case, the configuration file is /etc/apache2/mods-available/dav_svn.conf, and the changes are:

<Location /svn/reponame>
DAV svn
SVNPath /home/svn/reponame/
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>


Then restart apache:

sudo /etc/init.d/apache2 restart

2 comments:

gertmul said...

Do you know how to accomplish a repository move where you only have the contents of the whole svn folder...the original machine died before I could do a "dump"?

Luis Rocha said...

gertmul,

Subversion dump is just a convenient way to put all your subversion repository files into a single file format. It also allows you to make incremental dumps or revision specific.

If you still have your original subversion repository folder, you should be able to just copy it to your new machine. Note that the subversion repository folder contains the data (files with history) and the subversion repository configuration. You can follow the same steps above. You basically create a new empty repository on the new machine, copy all the files from the hard drive of the dead machine to the new empty repository folder (instead of restoring the dump), and reset the folder/files permissions as mentioned above.

I hope this helps.
Luis