Moving multiple subversion repositories

I needed to migrate all of our subversion repositories from an overworked machine onto a new dedicated machine. As I had about 30 repositories to copy over, I didn’t fancy doing each dump -> copy -> create -> import manually, so I came up with the following. Which, amazingly, worked the first time. I’d say a total of an hour elapsed from sitting down to start the job to being finished.

I’m running Debian Woody on the old machine and Debian Etch on the new one. Subversion was already installed on the new machine.

So, on the current svn server, dump out all of the repositories:

cd /export/svn
mkdir ../svn.dumps

for REPO in `ls`; do svnadmin dump $REPO > ../svn.dumps/$REPO.dump; done

Now copy over to the new machine. Ok, you *could* gzip each one first but I didn’t mind having to wait whilst it copied over.

cd ../
scp svn.dumps/* root@<other machine>:/export/dumps

On the new server su to root then and create the new repositories, import the dump files, change ownership and fix the file permissions:

su -
cd /export/dumps

for REPO in `ls | sed -e '/.dump/s/.dump//g'`; do
svnadmin create /export/svn/$REPO;
svnadmin load /export/svn/$REPO < $REPO.dump;
chown -R svn:svn /export/svn/$REPO;
find /export/svn/$REPO -type d -exec chmod 2770 {} ;
done

(wait quite a while)

Then create /etc/subversion/passwd and fill it with the contents from the old server.

Now you can either check out the projects again, or even easier (I didn’t script this bit) switch the location within the checked out project, for example:


cd /your/sandox/project/
svn switch --relocate svn://old/sever/repos/trunk svn://new/sever/repos/trunk

Job done.

Actually no

It turns out that I lied and there was one small thing that broke, I forgot to configure the authentication method on each repository in turn so you’d currently only have read access. To fix this all we need do is:

su -
cd /export/svn

for REPOS in `ls`; do echo "password-db=/etc/subversion/passwd
realm = YOUR REALM" >> $REPOS/conf/svnserve.conf; done

Which ensures that for each repository svn will use your central password file


Comments

3 responses to “Moving multiple subversion repositories”

  1. Eric Herrmann Avatar
    Eric Herrmann

    I know this is a *very* old post, but in case anyone stumbles upon this I thought I’d leave a comment. Unless you are moving to a different version of Subversion, or only want to keep certain ranges of commits, you can simply perform a filesystem-copy of the repository directory. The dump and load is overkill for most scenarios.

    Simply tar up /export/svn/$REPO, copy it to the new server and untar in /export/svn/. You could even rename it if you desired. The repository is fully contained in that directory, so there’s nothing else to do.

    1. Are you saying to tar up the folder with all the repos inside then copy to the other server?

      But if I want to update the new server with just new commits, once a day is it possible?

  2. I just migrated 100+ repositories by just copying repositories folder to new server (it has exactly the same path) and installing same svn sever version over there. To redirect working copies to a new svn server url all I need to use is svn relocate command.

Leave a Reply

Your email address will not be published. Required fields are marked *