This little tutorial for setting up a svn repository on a linux box is for all the new developers out there. It doesn’t matter if you are coding in in C++, Rails, PHP or what so ever. For other docs its also a good thing to have them versioned, so you don’t have to save several copies of your docs in ordinary folders. The differences of two Microsoft Word documents for example can be viewed in Word too.

Create the repository

Creating a Subversion repository is an incredibly simple task. The svnadmin utility, provided with Subversion, has a subcommand for doing just that. To create a new repository, just run:

$ svnadmin create /path/to/repos

This command creates a new file-based project svn archive in the given path. If you wanna stick with the old and good database version which uses the Berkeley DB, just type:

$ svnadmin create --fs-type bdb /path/to/repos

Configure the repository

After you created a new repository, you will have to setup access rights, because the standard option is set to read only for everyone. You can find the configuration file in

/path/to/repos/conf/svnserve.conf

To restrict the access only to authenticated users, that also get write permission, edit the configure file like that.

[general]
password-db = passwd
anon-access = none
auth-access = write
realm = My new subversion repository

Additional you can set a realm to identify your svn repository between other ones.

After restricting access to authenticated users, you have to add some users with password in the above given file

/path/to/repos/conf/passwd

Put in something like this.

[users]
username = password
user2 = secretpw

Now your configuration is done and you only need to start the svnserve daemon like that:

$ svnserve -d

The svn server is now listening on port 3690 for incoming connections.

Now you can use your new subversion repository from every place you can access your server. Just remember to forward the mentioned port  and that svnserve process has the rights to read and write in your file system.

Backup and Restore a repository:

Having all your files from your projects in the svn repository gives you the ability to get you old versions of your stuff, but if somethings goes wrong with your machine, you should backup your repository.

Here is how to do that:

$ svnadmin dump /path/to/repos > /tmp/repos.dump

And restore your data with

$ svnadmin load /path/to/reponame < /tmp/repo1.dump

Ok that’s it, now have fun and happy coding.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Facebook
  • TwitThis
  • LinkedIn
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • email
  • Webnews
  • Digg
  • StumbleUpon