Introduction

Version control systems like Subversion are considered essential tools for developers today. As per recent surveys, Subversion still has sizable installation base of over 5 million active repositories. However adoption trends shown below indicate shift towards distributed systems like Git in last decade:

[Insert graph showing SVN vs Git popularity over years]

Here are some key reasons teams still rely on Subversion:

  • Centralized model fits better for certain teams
  • Easier administration than distributed systems
  • Integrates well with existing systems/tools
  • Large existing codebases still under SVN
  • Gradual migration to Git, Mercurial etc

This guide aims to provide complete coverage of Subversion installation, configuration, customization, optimization and integration – both from perspective of developers as well as admins managing it in production systems.

We assume you have basic familiarity with version control concepts. Let‘s get started!

Prerequisites

Before installing Subversion, the Ubuntu server must meet following minimum requirements:

  • Ubuntu 18.04 or 20.04 LTS
  • Root access
  • Apache web server
  • Python 2.7
  • Network connectivity

Also keep in mind disk space requirements for hosting repositories. Here are some benchmarks:

Repository Size Disk Space
100 GB 200 GB
500 GB 1 TB
1+ TB 2+ TB

Allocate storage as per projected growth of repositories. We are using a server with 1 TB total storage in this guide.

Okay, let‘s now proceed with installing the components.

Installing Apache Web Server

As Subversion relies on Apache for network access via WebDAV protocol, first install the latest stable version using apt.

Update package index:

$ sudo apt update

Install Apache:

$ sudo apt install apache2

Verify status using systemctl:

$ sudo systemctl status apache2  

Apache should be active as shown above. If not, start the service:

$ sudo systemctl start apache2

And enable auto startup on reboot:

$ sudo systemctl enable apache2

Apache serves content from /var/www/html directory by default. Access the default page at http://serverip to confirm Apache is working.

With web server ready, we can now install Subversion next.

Installing Subversion and Dependencies

Use apt to install Subversion package. This also brings in other dependencies like libsvn, sasl etc:

$ sudo apt install subversion libapache2-mod-svn 

Additionally, enable dav_svn module which is required for Apache:

$ sudo a2enmod dav_svn

After install, restart Apache for changes to take effect:

$ sudo systemctl restart apache2

The Subversion binaries are now available in the system. Next we need to configure Apache properly to host repositories.

Apache Configuration for Subversion

The dav_svn module allows Apache to serve Subversion repositories over HTTP protocol.

Open its configuration file:

$ sudo nano /etc/apache2/mods-enabled/dav_svn.conf

Uncomment the following lines:

DAV svn
SVNParentPath /var/www/svn 

This enables the module and defines parent path for repositories.

Further down, update access details:

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user  

This specifies basic authentication using a credentials file at given location.

Save and exit file after making above changes.

Creating Repositories Directory

As per path configured earlier, create the directory which will host Subversion repositories:

$ sudo mkdir -p /var/www/svn  

Change ownership to www-data user and apache group:

$ sudo chown -R www-data:apache /var/www/svn

Update permissions to grant write access:

$ sudo chmod -R 775 /var/www/svn

These initial settings allow Apache to access the repositories hosted under this directory.

Defining Users and Access Control

We need to define usernames and passwords for securing Subversion access. These credentials get stored in dav_svn.passwd file referenced earlier.

To create a admin user with password admin123:

$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd admin

You can add more user accounts similarly:

$ sudo htpasswd -m /etc/apache2/dav_svn.passwd john

By default, Apache will use OS level permissions for repo access control. As repository structure evolves over time, maintaining these permissions can become complex.

For more granular permissions management independent of filesystem, consider using mod_authz_svn along with AuthzSVNAccessFile directive. Refer to Apache docs for details.

Alternatively, you can also integrate Apache with LDAP or Active Directory for enhanced authentication and organization based access policies.

Okay, this completes the baseline Apache configuration with mod_dav_svn enabled! Let‘s create our first repository next.

Creating Subversion Repository

With above steps done, we are now ready to create an actual Subversion repository to be served by Apache.

Use svnadmin which is the administration tool for managing repositories. Let‘s create one named myproject:

$ sudo svnadmin create /var/www/svn/myproject

Change ownership to www-data user:

$ sudo chown -R www-data:www-data /var/www/svn/myproject   

And update permissions:

$ sudo chmod -R 775 /var/www/svn/myproject

This completes setting up the first repository! You can similarly create additional repositories under same parent path.

Next, let‘s access this repository from client browser to confirm all configurations.

Accessing Subversion Repository

Our Subversion server is ready to serve repositories! Open web browser and access new repository using URL:

http://serverip/svn/myproject  

You should be prompted for username and password. Use credentials defined earlier.

This is the repository root checkout page. As expected, there are no files yet – but our Apache + Subversion integration is working!

Let‘s start version controlling projects by importing code and committing changes. But first, a quick look at basic Subversion commands.

Common Subversion Commands

Once repository is ready, developers can use following basic commands to version control projects:

Checkout code from repository:

$ svn checkout http://server/svn/project  

Add files/directories to version control:

$ svn add file_name
$ svn add *  

Commit changes:

$ svn commit -m "commit message"  

Update working copy:

$ svn update

Revision history:

$ svn log 

Restore files:

$ svn revert filename

Compare file differences:

$ svn diff
$ svn diff -r 100:200  

This covers common scenarios – commit new code, review history, fetch updates etc. Many more advanced capabilities available!

Now let‘s import sample project and commit some changes.

Importing and Version Controlling Sample Project

I have a basic PHP application containing two files – index.php and dbconfig.php. We will import this project into the Subversion repository created earlier.

The folder structure is:

myapp/
├── index.php
└── dbconfig.php

Navigate to this project folder in terminal:

$ cd myapp

Initialize the folder into SVN, with commit message:

$ svn import -m "initial commit" . http://serverip/svn/myproject   

This process "commits" the code into repository. Refresh repository browser page to confirm files now appear there.

Let‘s make some changes to this project. On local machine, edit dbconfig.php and update database credentials.

Check status:

$ svn status
M       dbconfig.php

File is shown modified. Commit changes:

$ svn commit -m "updated db credentials"

Now if you refresh repository view in browser, dbconfig.php would reflect updated revision!

This demonstrates basic workflow – modify files, review status, commit back to Subversion for others to sync changes.

We used command line client so far. Now let me show you graphical client integration on Windows.

Integrating TortoiseSVN Client on Windows

TortoiseSVN is a popular open source tool for Windows, providing tight Subversion integration in Explorer. Developers can perform commits, updates etc without using command line.

Download and install TortoiseSVN – make sure to include command line tools as well during installation wizard.

Once installed, right click inside any folder in Explorer. You will now see custom TortoiseSVN menu:

[image: TortoiseSVN menu]

Go to SVN Checkout option. Enter URL to our repository:

http://serverip/svn/myproject

Enter credentials when prompted. This would fetch latest version of files into local folder!

You can now access TortoiseSVN‘s rich feature set – commit changes by right click menu, inspect logs, resolve conflicts and so on.

For teams migrating from old tools like Visual Source Safe, TortoiseSVN provides that similar interface. It simplifies version control without command line usage.

Now that you have seen basics of hosting and accessing repositories, next section covers recommended practices when managing repositories in large teams and bigger codebases.

Repository Administration Best Practices

When using Subversion to version control large projects or products being actively developed, consider following guidelines:

Repository Layout

  • Logically separate components in own repositories instead of single giant repo
  • For example, have separate repos for frontend, backend, database etc
  • Keep third-party libraries in own repositories
  • Helps avoid unnecessary bloat and revisions overlap

Permission Management

  • Use dedicated user accounts per team instead of individuals
  • For example, have a dev-team1 account accessed by all developers in team 1
  • Reduces user administration effort as people join/leave

Branching Strategies

  • Maintain separate branches for development, QA, production releases
  • Only merge code after testing instead of direct commits to trunk
  • Use branching patterns like GitFlow that promote collaboration

Transitioning to Git

  • Prefer Git for newer components that don‘t have existing history in SVN
  • Slowly transition legacy Subversion repos to Git using tools like git-svn
  • Keep in sync for some time during transition

Adhering to conventions around layout, permissions, branching early on reduces maintenance effort as use scales up.

Now that you understand how to host Subversion and use it for project version control, next section covers integration with other tools for enhanced workflows.

Integrating Subversion with Other Tools

Subversion can be integrated with various other complementary tools:

Linking Commits with Issues Tracker

Link Subversion commits to tickets in issue tracker like JIRA or Bugzilla. This provides traceability between code changes to features and bugs.

Most trackers allow embedding ticket ID in commit messages, which can then be parsed and linked.

Automating Build and Deployments

Changes committed to Subversion can trigger Jenkins pipelines to:

  • Automatically build application
  • Run integration/regression tests
  • Deploy to staging for review
  • If approved, deploy to production

This automation eliminates manual steps and promotes collaboration in teams.

External Dependency Management

Tools like Artifactory act as proxy between your code and external libraries from repositories like Maven Central and npmjs.

For example, reference jquery from Artifactory instead of checking jQuery code directly into Subversion. This way build automation can fetch dependencies rather than you managing locally.

Subversion SDK and API

Subversion provides API and customization capabilities for developers via SVNKit, a pure Java framework.

You can directly interface Java applications with Subversion repository instead of command line usage.

As you can see, Subversion along with other tools can cover complete application lifecycle – from version control to issue management to continuous delivery.

Next section provides some guidelines around scaling and optimization that may be helpful as use increases.

Performance Tuning and Optimization

As number of users, activity volume and repository sizes increase in Subversion server, here are some aspects to consider for optimization:

Apache Configuration Tuning

Edit Apache‘s mpm settings for improved concurrent connections and throughput:

  • Increase max clients with ServerLimit
  • Adjust default thread count using ThreadsPerChild
  • Keep connections alive using KeepAlive

This allows more users to hit server simultaneously with minimal latency.

Caching Mechanisms

Enable Apache‘s default caching to avoid duplicate operations.

Also use tools like Squid proxy cache for improved performance especially over WAN. This reduces network overhead of remote Subversion commands.

Disk I/O Optimization

Use high performance disks like SSD for hosting repositories considering the file operations.

Distribute load across RAID volumes for better IOPS. Or attach high speed NAS storage.

These measures enhance commit, update and checkout speeds.

Handling Large Files

Subversion stores all file revisions which can bloat repo size. Manage growth using:

  • svndumpfilter to prune history
  • Limit log retention periods
  • Store large files externally using SVNSync

Additionally for text files like code, logs etc compress the changes instead of complete file using SVNDiff.

Scaling Hardware

Consider using a dedicated server or clustering configuration for hosting repositories:

  • Dedicated repo server separates load
  • Load balance traffic across Apache cluster
  • Replication for high availability

Provide adequate hardware sizing aligned to projected growth rates.

There are plenty more tuning and scaling options covered in docs. Apply above best practices proactively before performance bottleneck surfaces.

Next up is understanding migration from Subversion to the very popular Git ecosystem.

Migrating Repositories from Subversion to Git

Although Subversion excels at centralized source control, distributed systems like Git have become industry standard due to various factors:

Workflows: More support for complex branching strategies and non-linear development.

Access: No need for constant connectivity to central server. Entire code history available locally.

Ecosystem: Abundance of cloud services like GitHub, GitLab along with excellent tooling.

Admin Overhead: Comparatively simpler administration than running in-house Subversion infrastructure.

Hence many teams are considering migrating existing repositories in Subversion to Git for these reasons while retaining project history.

The git-svn tool allows such one-time migration of repositories, while retaining the complete change history. The high-level process consists of:

  • Take one time SVN repository dump using svndump
  • Migrate dump to Git with metadata using git-svn
  • Rewrite commit author info and emails
  • Push to Git server like GitHub/Gitlab internally

Post migration, both systems can run in sync for some duration allowing developers to adjust before shutting down Subversion completely.

There are some limitations around tracking renames, merges etc. Evaluate migration tools considering repository size, branches quality to avoid inconsistencies.

This concludes a comprehensive expert level guide on installing, configuring, integrating, optimizing and migrating Subversion deployments. Let‘s recap key aspects covered.

Summary

We went through complete process of hosting Subversion server on Ubuntu from ground up:

  • Introduced Subversion, use cases and adoption trends
  • Pre-requisites like Apache web server
  • Installation and configuration of mod_dav_svn
  • Creating user credentials and repositories
  • Importing projects, reviewing history, version control workflows
  • Integrations with tools like Jenkins, Artifactory
  • Best practices for permission, branching models
  • Performance tuning, hardware sizing guidelines
  • Options for migration to Git

We explored common admin tasks as well advanced configuration areas around security, automation, backup etc using a hands-on project.

This guide should provide you complete overview of managing Subversion environments – right from setting up your first repository through complex production grade deployment.

SVN remains trusted tool for version control in many enterprises thanks to centralized model and one-time effort of creating repositories. Integrate it with continuous integration, issue tracking and code review processes for developing applications efficiently in teams.

Hope you find this comprehensive Subversion administration guide useful. Let me know if any other aspects need to be covered!

Similar Posts