Skip to content

Posts from the ‘Subversion’ Category

18
Jul

Moving an SVN repository

Introduction

Moving an SVN repository between servers is easily performed using the svnadmin command. The process should take no more than 30 minutes but ultimately it depends on the size of the repository and how many commits have been made during the course of development. All changes performed against the repository are migrated resulting in no loss of version history or comments.

Note that this procedure can be used to migrate between Windows and Unix servers in either direction. The steps illustrated in this article have been performed on a Windows server. In brief, the steps are as follows:

  • Baseline the repository to be migrated
  • Extract contents of the repository
  • Create repository on the new SVN server
  • Import the extract to repository on the new SVN server

Baseline the repository to be migrated

Before you commence, ensure that all developers have committed their changes into the repository being migrated. It is also recommended that the SVN administrator performs a tag against the repository in the event that a rollback is required at a later date.

Extract contents of the repository

Assuming a parent directory called D:\Data\Development\SourceCode exists; extract the repository myproject as follows:

svnadmin dump D:/Data/Development/SourceCode/myproject > myproject-repository.extract

The output of this command will be similar to the following (which illustrates 12 revisions):

* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4.
* Dumped revision 5.
* Dumped revision 6.
* Dumped revision 7.
* Dumped revision 8.
* Dumped revision 9.
* Dumped revision 10.
* Dumped revision 11.
* Dumped revision 12.

If required, compress the extracted file prior to copying it to the new SVN server.

Create repository on the new SVN host

On the new SVN server, create the repository that you are going to import the extract into. For example:

svnadmin create myproject

You could create a repository on your new SVN server with a completely different name but for the sake of consistency the same name has been used.

Import the extract to repository on the new SVN server

Import the contents of the repository extract into the new repository as follows:

svnadmin load myproject < myproject-repository.extract

Conclusion

This post outlined the process for moving an SVN repository between servers without any loss of version history. The same procedure can be followed if you require a duplicate copy of an SVN repository on the same server using a different repository name.

13
Jul

Installing and configuring SVN for HTTP access

Introduction

This article outlines the procedure for setting up Subversion (SVN) on Windows and configuring it for use with Apache so that it can be accessed via HTTP. In brief, the steps are as follows:

  1. Install SVN
  2. Create an SVN repository
  3. Verify and populate the repository
  4. Install and configure Apache HTTP server
  5. Create the SVN access control list for authorisation
  6. Create the authentication file
  7. Validate access to project repository

Using a custom module, httpd makes Subversion repositories accessible to clients via the WebDAV/DeltaV protocol which is an extension to HTTP 1.1

Install SVN

Download the latest SVN binaries from http://subversion.apache.org/

Extract binaries to the file system and add the SVN bin directory to the command-prompt path.

Create the Repository

There are two options for creating repositories: one per project or one for all projects. This example will use the former approach as it provides more granularity with regards to project actions such as source-code commits or creation of branches and tags.

Assuming a parent directory called D:\Data\Development\SourceCode exists; create the repository myproject as follows:

svnadmin create D:/Data/Development/SourceCode/myproject

Next, create a temporary directory structure on your file system in another location for performing the initial repository import. This temporary directory will be deleted later once the import has taken place. The structure might look like the following:

C:/temp
    /myproject
        /branches
        /tags
        /trunk

Change to the c:\temp directory and issue the following command:

svn import ./myproject file:///D:/Data/Development/SourceCode/myproject --message "Initial repository layout"

You should see the following message at the prompt:

Adding         myproject\trunk
Adding         myproject\branches
Adding         myproject\tags

Committed revision 1.

Verify the repository

Verify the contents of the SVN repository as follows:

svn list --verbose file:///D:/Data/Development/SourceCode/myproject

Populate the repository (optional)

Using an SVN client such as TortoiseSVN, connect to the repository and import the project contents into the /trunk directory of the module.

Install and configure Apache HTTP server

Download the latest Apache (2.x) installation binaries from http://httpd.apache.org/download.cgi then install making note of the server and port settings.

Copy the files mod_authz_svn.so and mod_dav_svn.so from your Subversion /bin directory into the /ApacheSoftwareFoundation/Apache2.2/modules/ directory.

Edit the Apache httpd.conf file as follows:

Uncomment the following line:

LoadModule dav_module modules/mod_dav.so

Add the following lines:

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

At the end of the file, include a reference to the SVN configuration file svn.conf. We will create svn.conf in a later step.

# File containing SVN settings
Include D:/Data/Development/SourceCode/svn.conf

As part of this configuration, a decision to prevent anonymous access to repositories has been made. Furthermore, the only people who can modify the contents of a project’s repository will be the developers working on the specific project who have been provisioned with accounts.

Create SVN access control list for authorisation

Create a file for user authorisation called svn-acl. This file should list the project repositories and specify user and group access rights on a per-repository basis. Assuming the need to grant read/write access to the developers group to the myproject repository, enter the following in this file:

#
# specify groups here
#
[groups]
developers = greg, chris, james

#
# developers group has a read/write access to myproject repository
# all others have no access
#
[myproject:/]
@developers = rw

Create the authentication file

Next, create an empty file for user authentication called svn-auth. All developers using the SVN server must specify a username and password.

C:\Applications\ApacheSoftwareFoundation\Apache2.2\bin\htpasswd -m D:\Data\Development\SourceCode\svn-auth greg
New password: *****
Re-type new password: *****
Adding password for user greg

If you view the contents of the file it will be similar to the following showing a separate line-entry for each user that has been granted access:

greg:$apr1$eyu2G7pC$GW/.B/1HmHv6WO8b8/JAO1
chris:$apr1$VlP36oHa$plPC4QsyLiL5VGr2txdzX0
james:$apr1$Jry1Nldr$7adGZ6NaaGpO9KE/94bV/.

Passwords in this file have been encoded using the MD5 algorithm.

Create SVN configuration file for Apache

Next, you must link SVN with the Apache server by editing the contents of the svn.conf file.

<Location /svn/myproject>
  DAV svn
  SVNPath D:/Data/Development/SourceCode/myproject

  AuthType Basic
  AuthName "Subversion repository for myproject"
  AuthUserFile D:/Data/Development/SourceCode/svn-auth

  Require valid-user

  AuthzSVNAccessFile D:/Data/Development/SourceCode/svn-acl
</Location>

Note that the value specified in the tag is the URL for the project repository.

Restart the Apache HTTP server so that configuration changes can take effect.

Validate access to project repository

Developers should be able to access the project repository by launching a web browser and entering the URL for the project. This will be the Apache hostname, for example http://bobcat.comdynamics.net followed by the project repository location such as /svn/myproject to give a URL similar to the following structure: http://bobcat.comdynamics.net/svn/myproject

When navigating to this URL using a web browser you will be prompted to supply credentials.

Apache SVN Basic Authentication

Upon successful entry of credentials at the HTTP basic authentication prompt you should be able to browse the SVN project repository.

SVN Repository Project Listing

Conclusion

This post outlined installation and configuration of SVN, creation of a project repository, and exposing the repository for access via HTTP to a team of developers. Future articles will discuss configuring SVN to use LDAP for user repository authentication and authorisation.