SVN (Subversion)


SVN, like CVS and RCS, is a revision control application. I want to use this for web developing (for me and Brent), my perl/bash code, and anything else that makes sense to put into SVN… (maybe I'll stick /etc into there or something)


First we must install SVN.

  1. add the following to /etc/make.conf:
    .if ${.CURDIR:M*/devel/subversion*}
  2. add the following to /usr/local/etc/pkgtools.conf (in the MAKE_ARGS section):
       'devel/subversion*' => [
  3. go into the ports subversion directory and run make:
    # cd /usr/ports/devel/subversion
    # make install clean


There are two different methods one can use to run an SVN server:

  • svnserv
  • apache

The follow procedure is for the Apache method (it provides secure access when using https://):

  1. setup your repository:
    # mkdir /usr/local/svn
    # svnadmin create /usr/local/svn/web
    # chown -R www:www /usr/local/svn/web
  2. Create /usr/local/etc/apache22/extra/httpd-svn-authz.conf with the following content:
       <Location /svn>
        DAV svn
        SVNParentPath /usr/local/svn
        # Subversion repository ACL file
        AuthzSVNAccessFile /usr/local/www/apache22/auth/svn-access
        # prevents anonymous access
        Require valid-user
        # Apache Authorization configuration
        AuthType Basic
        AuthName "thoughtbit repositories"
        AuthUserFile /usr/local/www/apache22/auth/svn-auth
        # Rewrite all requests to https to ensure encrypted passwords
        RewriteEngine On
        RewriteCond %{HTTPS} !on
        RewriteRule ^/(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R]
  3. add the above httpd-svn-authz.conf to /usr/local/etc/apache22/httpd.conf:
    # Subversion repostories
    Include etc/apache22/extra/httpd-svn-authz.conf
  4. Since we are forcing our svn access to go over https:, we need to add our CustomLog directive to /usr/local/etc/apache22/extra/httpd-ssl.conf, right after the other CustomLog directive:
    <code> # log for subversion CustomLog /var/log/httpd-svn.log “%t %u %{SVN-ACTION}e” env=SVN-ACTION </code> - create the AuthUserFile (
    <code> # cd /usr/local/www/apache22 # mkdir auth # chgrp www auth # chmod 2750 auth # cd auth # htpasswd -cm svn-auth john and for additional users: # htpasswd -m /usr/local/www/apache22/auth/svn-auth bob </code> - create the AuthzSVNAccessFile (
    <code> # svn access file # # created Aug 11, 2007 2:23am by john # gives access to the web repository from the root down [web:/] john = rw </code> - import your data: - first prepare the source:
    <code> $ mkdir thoughtbit $ cd thoughtbit $ mkdir trunk branches tags $ cp -R /your/source/code/* trunk/ $ cd .. </code> - and import:
    <code> $ svn import thoughtbit https://shalom/svn/web/thoughtbit -m “initial import” </code> - since this is based on my current “production” website, I'll create a
    tag to designate the release-1.0 snapshot:
    <code> $ svn copy https://shalom/svn/web/thoughtbit/trunk \ > https://shalom/svn/web/thoughtbit/tags/release-1.0 \ > -m “intial release-1.0 based on initial import of code” </code> <note tip> To copy repositories, run the following commands (where myrepos is a currently existing repository to be copied to the new “newrepos” repository):

    <code> $ svnadmin create newrepos $ svnadmin dump myrepos | svnadmin load newrepos </code> </note> ===== Backup via cron ===== It's probably a good idea to configuration automatic backups of the SVN repository. I am going to use the
    /usr/local/share/subversion/backup/ program to handle the backups (and only keeping the most recent backups on the filesystem), and cron to schedule this daily. <note note> I need to setup a backup user who has read access to the subversion directory, and run the cronjob as that user… </note> - create a backup location:
    <code> # cd # pwd # /root # mkdir -p backup/svn # mkdir -p backup/scripts </code> - we need to create the backup script: - <code># cd backup/scripts</code> - <code># vi</code> - paste the following into, and adjust accordingly:
    <code bash> #!/usr/local/bin/bash # # Subversion Repository Backup Script # # created 5:20am 12 Aug 2007 by John Friar # Subversion Repository Backup Location: BACKUPDIR=/root/backup/svn/ # The root directory (your repositor[y|ies] [is|are] inside this directory): REPOROOT=/usr/local/svn/ # List the repositor[y|ies] you want backed up: REPOLIST=“web” # Archive type (options: bz2, gz, zip): ARCHTYPE=“bz2” # The python script location: HOTBACKUP=/usr/local/share/subversion/backup/; # Python binary location: PYTHON=/usr/local/bin/python; for i in ${REPOLIST}; do ${PYTHON} ${HOTBACKUP} –archive-type=${ARCHTYPE} ${REPOROOT}${i} ${BACKUPDIR} done </code> - make the backup script executable:
    <code> # chmod 750 </code> - test the script:
    <code> # ./ </code> - add the script to
    <code bash> # # Backup Subversion repositories 45 6 * * * root /root/backup/scripts/ </code> ===== Reference Links ===== * - guide to installing/configuring SVN on FreeBSD * - the free SVN book * * - a slick GUI client for SVN * * * * - repository backup information ==

freebsd/svn.txt · Last modified: 2009/03/01 04:03 by john
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki