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
Leave a Reply