
Have it all, with benefits including: reliability, performance and a solid backup solution. Learn how you can setup a hosted Subversion server for your team in minutes … oh, and did I mention its pretty cheap too!
This guide will cover, from start to finish, how to setup you very own hosted Subversion (SVN) server with a full backup solution.
The background:
I’ve been using Subversion for about 2 years now. I started using it myself for my own projects and intoduced it to Hitch about a year ago. My original setup was a small sized Windows XP desktop machine using a simple svnserve setup. The machine was on a remote Comcast Cable connection (cable connections typically cap your UP speed so things can get pretty slow). And, because half of our team at Hitch was using the server, performance and speed was becoming an issue.
Often times the cable connection would go down, or the server needed rebooting. Additionally data backups were sketchy.
Setting up an SVN server is not difficult, and some of you probably have one running already. The setup I am going to go over will use a default Rackspace Could Server instance and uses the svnserve deamon (basic SVN at its best).
Getting started with Rackspace Could Server
Rackspace has some great pricing for their Could Servers. For this setup all I needed was the entry level server at 256MB/10GB @ 1.5c/hr (roughly $11 monthly). There are also bandwidth in/out and backup storage costs which are negligible.
All and all the server costs less than $15 a month to operate, yet it comes with the key benefits of reliability (up-time), performance (very nice up/down speeds) and a solid backup solution. Creating an account is easy and I totally recommend using Rackspace.
Creating the Server
- After creating your account with Rackspace, login.
- Click on “Hosting” from the options on the left, then select “Cloud Servers”.
- Click the “Add Server” button.
- You can select your desired Operating System (OS), for this guide I’ve selected Ubuntu 8.04.2 LTS – hardy heron (Subversion on Linux is easy and the Ubuntu community has great support).
- You will be prompted to give your new server a name and select a size (256MB/10GB should be more than enough for a basic setup), click the “Create Server” button.
- The server will take a few minutes to spin up. You will be presented with server information and you will also recieve an email with all the details. Make a note of the IP address and your root password (you will use it later to login via SSH, to configure the server).
Setting Up Scheduled Image Backups
- Now select the “Images” tab and click the “Enable Scheduled Imaging” button.
- Select a time for the daily backup (0000-0200) and a day for the weekly backup (Saturday). Click the “Save Schedule” button.
Rackspace has two locations where the backup images are stored:
- With Server: Images located with the server will be deleted if you destroy their parent server.
- Cloud Files: Images located in Cloud Files will remain there even after deleting their parent server.
By default your backups will be stored “With Server”, this isn’t necessarily a bad thing, since your server instance is pretty resilient.
To enable Cloud Files storage, I had to make a request to Rackspace via a support ticket, Rackspace was quick to respond and in about an hour I was all setup.
Moving backups to Cloud Files is as easy as cliking a “move” link. The only annoyance is that Rackspace doesn’t appear to have a way to move backup images into Cloud Files storage automatically on a schedule.
However, Cloud Files does have an API which can probably be used via a cron script to move a “With Server” backup image to a Cloud Files storage container (I have not tested this and am making an assumption that this should be possible).
Configuring the Server with Subversion
Well it’s time to get to the nitty-gritty… You will need an SSH client for this (I’m using PuTTY).
- Open PuTTY, enter in your server’s IP address and use port 22 (SSH), then click the “Open” button.
- PuTTY will prompt you to cache your connection, so click the “Yes” button.
- Login as
root, use the root password you were given during setup (check your email, it’s there too).
Once you’ve started your SSH session, you will execute a series of commands and make some file edits to get your server all setup.
First lets get the server up-to-date with the most recent packages.
# sudo apt-get update
# sudo apt-get upgrade
Next lets install subversion and xinetd (which we will use to manage connections to svnserve).
# apt-get install subversion subversion-tools xinetd
Now we will create a default repos directory where we can store all our subversion repositories. We will also create our first repository. You can change myrepo to a different name if you want.
# mkdir /repos
# svnadmin create /repos/myrepo
There are a few strategies for managing the structure inside a repository, but that’s beyond the scope of this tutorial. The approach I use and am recommending is the following:
/myrepo
/myrepo/project-a
/myrepo/project-a/trunk
/myrepo/project-a/tags
/myrepo/project-a/branches
/myrepo/project-b
/myrepo/project-b/trunk
/myrepo/project-b/tags
/myrepo/project-b/branches
It’s one repository for all your projects. I’ve been using this structure very successfully, additionally this setup makes it easy to cherry-pick bigger projects and put them in their own repository in the future (you will probably never need to do this).
Back to the setup; We will be using a little bit of vim (a super fly Linux text editor) to do a bit of config file editing, so here is a quick primer on using vim:
Open files with the following command:
# vim /path/to/the/fileOnce you’ve opened a file, enter editing mode by pressing
i. You will now be able to make changes to the file.Use the
directional arrowson your keyboard to navigate.When you are finished editing press
ESC, this will exit the editing mode. To save the file enter:wq(write and quit).If you want to exit without saving, enter
:q!
Now, lets add a user for our repository, open the repository’s passwd file:
# cd /repos/myrepo/conf
# vim passwd
Using your vim skills, and the examples in the file, add the following to the end of the file, and then save it:
myusername = mypassword
Now lets set the user with read/write access to the entire repository, open the repository’s authz file:
# vim authz
Add the following to the end of file, then save it:
[/] myusername = rw
Finally we need to adjust the config file, open the repository’s svnserve.conf file:
# vim svnserve.conf
Edit it so it looks like this:
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
realm = My First Repository
Almost done, now we will configure xinetd to manage connections to the svn server. We will need to create a new config file for xinetd:
# vim /etc/xinetd.d/svnserve
Add the following to this file:
service svn
{
port = 3690
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/svnserve
server_args = -i -r /repos
}
Save the file and exit. Now restart the xinetd daemon.
# /etc/init.d/xinetd restart
Thats it!
Checkout Your Repository
At this point your server should be all set, it’s now time for you to do a checkout of your new repository.
Most of my day-to-day development is done on a windows environment, so I use TortiseSVN as my client. Gaird @ Hitch Creative is a Mac user and he uses Versions.
Using your SVN client of choice, do a checkout of your repository at:
svn://[SERVER_IP_ADDRESS]/myrepo

Nice post. However, I’d suggest using SVNManager (http://svnmanager.org) which is based on PHP and after the initial configuration, lets you manage everything on the GUI. Cheers!
@Emran, thanks for the link, looks interesting, hopefully it functions well enough for day to day use. I’ve tried http://warehouseapp.com in the past but it lacks in a few areas…
So it’s been a couple of months now, hows it working out? Any other additions to the features on your server other than just SVN, or are you still doing it all command line? I am on the verge of doing this exact same thing myself.
Hi Joshua, Rackspace has been working out quite nicely for SVN, because the SVN server is really low maintenance, I still do all of the administration via command line (which isn’t much, I think I logged in less than a handful of times in the last 3 months).
This also probably has to do with the way I have the repo setup. I use one main repo which contains several projects:
/repo
/repo/a/trunk
/repo/a/branches
/repo/a/tags
/repo/b/trunk
/repo/b/branches
/repo/b/tags
Most of my day to day stuff is done with TortoiseSVN (all point and click).
If you’ve seen my other articles, I’ve also been playing with LEMP … the great thing about Rackspace is that its really easy to spin up a server, do test installs and just play around.
I already use RackSpace Cloud Sites for my webhosting. However I would have to install a webserver for any type of GUI on an SVN box, you have me intrigued with LEMP I have always just used LAMP. I will have to read your post.
i am configure SVN Server on RHEL 5 .When i am project team share the project containt is not save on SVN Server.Please help me
Hey, thanks for this tutorial. Im giving it a run now, but ran into a quick snag…
After typing “svnadmin create /repo/myrepo” i get this error:
svnadmin: Repository creation failed
svnadmin: Could not create top-level directory
svnadmin: Can’t create directory ‘/repo/myrepo’: No such file or directory
Any ideas how i can fix this to proceed to the next step? Thanks!
@CakePlease, keep in mind that some of these commands will require root access. You should do:
sudo svnadmin create /repo/myrepoor switch to root firstsudo suand thensvnadmin create /repo/myrepo.Thanks Dimas. Im not linux guru…but worked. All the other steps worked as well.
However when i do a checkout via tortoise, i get a error: Malformed network data… bleh.
I have one suggestion to add to your article, or possible a new one. Maybe you can show how to tie the server IP to some DNS? So like:
svn://SERVER_IP_ADDRESS/myrepo
would function as:
svn://svn.mydomain.com/myrepo
Thanks
Great post, worked like a charm, thank you for writing it up!