Migrate SVN repository from "ssh+svn" to "svnserve"
Posted: Mon Mar 31, 2014 12:43 pm
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:
On the old svn server, use "svnadmin dump":
Compress that file:
You should now have a .bz2 file of your SVN repository dump:
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:
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:
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:
Now, unpack the bz2 file, so you have the cleartext dump (.dmp) file.
Create a new, empty repository and import (=load) the dump:
It will display each imported revision during import, and halt, displaying info about the last commit:
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":
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".
The following command creates an inetd config for svnserve, pointing it at "/srv/svn":
Make sure you don't have any svnserve daemon running and restart "inetd":
If you should have problems connecting to svnserve, stop the inetd service and check your authentication configuration, by starting the svnserve daemon manually:
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:
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:
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:
I'd like to move it to another GNU/Linux machine, but in a less user-focused location:/home/me/repositories/dingo
Create a dump file of the current (=old) repository:/srv/svn/dingo
On the old svn server, use "svnadmin dump":
Code: Select all
$ svnadmin dump /home/me/repositories/dingo > ~/svn_dump-dingo.dmp
Code: Select all
$ bzip2 -9 ~/svn_dump-dingo.dmp
Code: Select all
~/svn_dump-dingo.dmp.bz2
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
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
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/
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
NOTE: At this point, you might want to verify that your repository files in "/srv/svn/dingo" all belong to user:group "svn:svn".------- 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 >>>
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
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
Code: Select all
$ echo "svn stream tcp nowait svn /usr/bin/svnserve svnserve -i -r /srv/svn" > /etc/inetd.d/svnserve
Code: Select all
$ service inetutils-inetd restart
Code: Select all
$ sudo svnserve -d -r /srv/svn/
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 .
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: