Migrate SVN repository from "ssh+svn" to "svnserve"

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Migrate SVN repository from "ssh+svn" to "svnserve"

Post by ^rooker »

I've been using an SVN repository for myself, without any multi-user support, simply by accessing it directly over SSH under my user account.

That's nice, but as soon as you need more than one user committing to that repo, it's not sufficient anymore. So, I'm migrating a single-user repository to a Debian 6 (Squeeze), using "svnserve" for future access.


So, let's assume my current repository is called "dingo" and located in the following path:
/home/me/repositories/dingo
I'd like to move it to another GNU/Linux machine, but in a less user-focused location:
/srv/svn/dingo
Create a dump file of the current (=old) repository:
On the old svn server, use "svnadmin dump":

Code: Select all

$ svnadmin dump /home/me/repositories/dingo > ~/svn_dump-dingo.dmp
Compress that file:

Code: Select all

$ bzip2 -9 ~/svn_dump-dingo.dmp
You should now have a .bz2 file of your SVN repository dump:

Code: Select all

~/svn_dump-dingo.dmp.bz2
Create a user and group to be the "SVN Owner":
On the new SVN server, we'll call the user and group "svn" and create it as system account, so it will have a UID/GID below 1000:

Code: Select all

$ sudo groupadd -r svn
$ sudo useradd -c "SVN Owner" -r -g svn -d /srv/svn -M -s /bin/false svn
Copy the bz2-dumpfile to the new server:
First, you need to create the SVN target location on the new server, and then copy the dump bz2-file:

Code: Select all

$ mkdir -p /srv/svn
$ chown svn:svn /srv/svn
The second command, changes the ownership to "svn:svn".

You can copy the dump-file using whatever method/tool you prefer. I use "scp" (secure copy) over SSH. For example:

Code: Select all

$ scp me@old-server:~/svn_dump-dingo.dmp.bz2 /srv/svn/
Now, unpack the bz2 file, so you have the cleartext dump (.dmp) file.

Create a new, empty repository and import (=load) the dump:

Code: Select all

$ svnadmin create /srv/svn/dingo
$ cat /srv/svn/svn_dump-dingo.dmp | svnadmin load /srv/svn/dingo
It will display each imported revision during import, and halt, displaying info about the last commit:
------- Committed revision 194 >>>

<<< Started new transaction, based on original revision 195
* adding path : scripts/storage ... done.
* adding path : scripts/storage/mkraid.sh ... done.

------- Committed revision 195 >>>
NOTE: At this point, you might want to verify that your repository files in "/srv/svn/dingo" all belong to user:group "svn:svn".

Setup SVN authentication:
In the repository folder, we've just created and filled, edit the "conf/svnserve.conf" file.
Follow the instructions of red-bean.com's SVN documentation about svnserve authentication.

In my setup, I've added the following lines to the "[global]" section in "conf/svnserve.conf":

Code: Select all

### My server settings:
password-db = passwd
realm = My own SVN realm
# anonymous users can only read the repository
anon-access = read
# authenticated users can both read and write
auth-access = write
Then, add/edit the users you want to have access to your SVN repository in the "conf/passwd" file.

Start the "svnserve" daemon:
Svnserve does not have an init-script on Debian (See Debian bug-report #352584)

It seems that the preferred method for running svnserve is to use "inetd".

Code: Select all

$ apt-get install inetutils-inetd
The following command creates an inetd config for svnserve, pointing it at "/srv/svn":

Code: Select all

$ echo "svn stream tcp nowait svn /usr/bin/svnserve svnserve -i -r /srv/svn" > /etc/inetd.d/svnserve
Make sure you don't have any svnserve daemon running and restart "inetd":

Code: Select all

$ service inetutils-inetd restart
If you should have problems connecting to svnserve, stop the inetd service and check your authentication configuration, by starting the svnserve daemon manually:

Code: Select all

$ sudo svnserve -d -r /srv/svn/
If everything works, don't forget to kill that daemon, before you start debugging your inetd config.

Checkout your new SVN:
You should now be able to checkout your migrated repository "dingo", using the following command:

Code: Select all

$ svn checkout --username <your_user> svn://<svn_hostname>/dingo .
That's it. :)

NOTE: This is far from perfect and clean, but it should give you a good idea about the basics for migrating an SVN repository to svnserve.


Links:
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply