Moving Subversion Repository Across Machines

I recently moved my development server from a linux box to my primary machine, an iMac. I wanted to move my subversion repository while maintaining the file histories for everything inside. Worrying that it was going to be a huge issue, I was happy to discover it was completely simple:

On the existing repository machine, run:

svnadmin dump /path/to/repository > repository-name.dmp

Transfer your dump file to the new machine and then, create a repository. Once subversion is running and you have your repository created, import the dump file:

svnadmin load /path/to/repository-name< /path/to/repository-name.dmp

You’re done!

Setting up Subversion on Mac OS X 10.5

I recently began working exclusively on an iMac so I decided to setup a subversion server locally and as my new machine would simply replace my local development machine, which is a Fedora Core 6 pc.

You’ll need to setup at least one repository. I’m going to need multiple repositories that I can use for different clients so I have a bit of extra admin work ahead of me. You can setup as many repositories as you need, but no matter what you’ll need at least one. Here create the folders…

# mkdir /svn
# mkdir /svn/repos

Then we need to tell subversion to make our first repository.

# svnadmin create /svn/repos/myproject

First, I need to setup a config file for svnserve.

# vi /svn/repos/conf/svnserve.conf

Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.

anon-access = none
password-db = passwdfile
realm = My SVN Repository
auth-access = write

The password-db is just a path to a file containing usernames and passwords. You’ll create this file especially for SVN. I create each file inside of the repository conf directory. So, save your changes and then we’ll create said user file.

# vi passwdfile

Enter in something like:

[users]
username = password

Anyway, you’ll need to start the svn server.

# svnserve -d --listen-port=3690

One side note - svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.

# killall svnserve

Then, go ahead and test (best to do so on a different machine).

# svn co --username=myusername svn://mydomain/svn/repos/myproject

The system should then ask you for your password. Go ahead and run some tests.

CVS to Subversion Transfer

Most of my projects all use Subversion now, as everyone knows it’s the recommended little brother of CVS. However, for everything that doesn’t have a home in SVN with a client, I was storing in CVS I had running on my local dev machine.

Not wanting to loose any of my files or their histories, I wanted to find a way to transfer everything into subversion. At the recent ZendCon I heard about cvs2svn and I tried it out. It was very easy to install (required Python, which was easy for me to installed through Yum), and it was easy to run - at least for me as I was just pulling everything over.

Now I’ve got everything in subversion and I was able to maintain the file histories for everything.

Installing Subversion on Fedora Core

I’ve been using subversion a lot recently - from using repositories with client development companies to installing it for clients - it seems to be the SVN month.

Here’s how I installed subversion on a machine with Fedora Core 4. For anyone learning or using Subversion, I highly recommend that you read the book.

You may already have subversion installed, if not, just run this:

# yum install subversion
# yum install mod_dav_svn

Then you’ll need to setup at least one repository. I’m going to need multiple repositories that I can use for different clients so I have a bit of extra admin work ahead of me. You can setup as many repositories as you need, but no matter what you’ll need at least one. Here create the folders…

# mkdir /svn
# mkdir /svn/repos
# mkdir /svn/users
# mkdir /svn/permissions

We need to give these folders the proper permissions

# chown -R apache.apache /svn

Then we need to tell subversion to make our first repository.

# svnadmin create /svn/repos/myproject

First, I need to setup a config file for svnserve.

# vi /svn/repos/conf/svnserve.conf

Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.

anon-access = none
password-db = passwdfile
realm = My SVN Repository
auth-access = write

The password-db is just a path to a file containing usernames and passwords. You’ll create this file especially for SVN. I create each file inside of the repository conf directory. So, save your changes and then we’ll create said user file.

# vi passwdfile

Enter in something like:

[users]
username = password

Anyway, you’ll need to start the svn server.

# svnserve -d --listen-port=3690

One side note - svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.

# killall svnserve

Then, go ahead and test (best to do so on a different machine).

# svn co --username=myusername svn://mydomain/svn/repos/myproject

The system should then ask you for your password. Go ahead and run some tests.

Now, let’s setup apache.

Create a new apache include file that will hold our configurations (You may already have this is subversion was already installed).

# vi /etc/httpd/conf.d/subversion.conf

Now, this file will need to contain something like this to serve the repository through apache:


LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so


DAV svn
SVNPath /svn/repos
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /svn/users/svnpass
Require valid-user
AuthzSVNAccessFile /svn/permissions/svnauthz.conf

Now, this essentially tells apache to load the mods needed for svn. We need to create some files so that this config will work properly. The first is our htpasswd file which I named “/svn/users/svnpass”.

# htpasswd -cb /svn/users/svnpass username password

Next we need to create the svnauth file.

# vi /svn/permissions/svnauthz.conf

Inside we’ll place a list of users who have access to files:


[/]

username = rw

The “rw” states that this user has read/write access to the root repository /.

Restart your web server and you should be done.

service httpd reload
or you can use:
/usr/sbin/apachectl restart - this option outputs better error messages in case you’ve made some syntax mistakes.

Go to your repository and you should see subversion displaying the repo info.

http://yoursite.com/svn/repos/

Installing Subversion on CentOS

I’ve been using subversion a lot recently - from using repositories with client development companies to installing it for clients - it seems to be the SVN month.

Anywhere, here’s how I did it. Using CentOS 4.2. For anyone learning or using Subversion I highly recommend that you read the book.

First you need to get the package and install it.

# wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
# gunzip subversion-1.3.2.tar.gz
# tar -xvf subversion-1.3.2.tar
# cd subversion-1.3.2
# ./configure
# make
# make install

Then you’ll need to setup at least one repository. I’m going to need multiple repositories that I can use for different clients so I have a bit of extra admin work ahead of me. You can setup as many repositories as you need, but no matter what you’ll need at least one. Here create the folders…

# mkdir /svn
# mkdir /svn/repo

Then we need to tell subversion to make our first repository.

# svnadmin create /svn/repo/myproject

For the time being, I’ll use the default svn server called svnserve. You can use apache to get a ton of extra features and better security. Click here for more information on using Apache with subversion. I need do some additional research for my multiple-repository setup before switching to apache though.

First, I need to setup a config file for svnserve.

# vi /svn/repo/conf/svnserve.conf

Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.

anon-access = none
password-db = passwdfile
realm = My SVN Repository
auth-access = write

The password-db is just a path to a file containing usernames and passwords. You’ll create this file especially for SVN. I create each file inside of the repository conf directory. So, save your changes and then we’ll create said user file.

# vi userfile

Enter in something like:

[users]
username = password

Yes, pretty basic. See what I meant about svnserve and security? The password is in plain text so if someone ever got your system or that file, they’ll have the passwords inside. That’s one more reason to move to apache.

Anyway, you’ll need to start the svn server.

# svnserve -d

One side note - svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.

# killall svnserve

Then, go ahead and test (best to do so on a different machine).

# svn co --username=myusername svn://mydomain/svn/repo/myproject

The system should then ask you for your password and off you go!