====== SVN (Subversion) ====== ===== Information ===== 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) ===== Installation ===== First we must install SVN. - add the following to ''/etc/make.conf'':\\ .if ${.CURDIR:M*/devel/subversion*} WITH_PERL=yes WITH_MOD_DAV_SVN=yes WITH_APACHE2_APR=yes WITH_BERKELEYDB=db41 WITH_SVNSERVE_WRAPPER=yes .endif - add the following to ''/usr/local/etc/pkgtools.conf'' (in the MAKE_ARGS section):\\ 'devel/subversion*' => [ 'WITH_PERL=yes', 'WITH_MOD_DAV_SVN=yes', 'WITH_APACHE2_APR=yes', 'WITH_BERKELEYDB=db41', 'WITH_SVNSERVE_WRAPPER=yes', ], - go into the ports subversion directory and run ''make'':\\ # cd /usr/ports/devel/subversion # make install clean ===== Configuration ===== 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://%%): - setup your repository:\\ # mkdir /usr/local/svn # svnadmin create /usr/local/svn/web # chown -R www:www /usr/local/svn/web - Create ''/usr/local/etc/apache22/extra/httpd-svn-authz.conf'' with the following content:\\ 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] - add the above ''httpd-svn-authz.conf'' to ''/usr/local/etc/apache22/httpd.conf'':\\ # Subversion repostories Include etc/apache22/extra/httpd-svn-authz.conf - 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:\\ # log for subversion CustomLog /var/log/httpd-svn.log "%t %u %{SVN-ACTION}e" env=SVN-ACTION - create the AuthUserFile (''/usr/local/www/apache22/auth/svn-auth''):\\ # 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 - create the AuthzSVNAccessFile (''/usr/local/www/apache22/auth/svn-access''):\\ # svn access file # # created Aug 11, 2007 2:23am by john # gives access to the web repository from the root down [web:/] john = rw - import your data: - first prepare the source:\\ $ mkdir thoughtbit $ cd thoughtbit $ mkdir trunk branches tags $ cp -R /your/source/code/* trunk/ $ cd .. - and import:\\ $ svn import thoughtbit https://shalom/svn/web/thoughtbit -m "initial import" - since this is based on my current "production" website, I'll create a ''tag'' to designate the ''release-1.0'' snapshot:\\ $ 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" To copy repositories, run the following commands (where myrepos is a currently existing repository to be copied to the new "newrepos" repository): \\ \\ $ svnadmin create newrepos $ svnadmin dump myrepos | svnadmin load newrepos ===== 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/hot-backup.py'' program to handle the backups (and only keeping the most recent backups on the filesystem), and ''cron'' to schedule this daily. I need to setup a backup user who has read access to the subversion directory, and run the cronjob as that user... - create a backup location:\\ # cd # pwd # /root # mkdir -p backup/svn # mkdir -p backup/scripts - we need to create the backup script: - # cd backup/scripts - # vi svn-backup.sh - paste the following into ''svn-backup.sh'', and adjust accordingly:\\ #!/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 hot-backup.py python script location: HOTBACKUP=/usr/local/share/subversion/backup/hot-backup.py; # Python binary location: PYTHON=/usr/local/bin/python; for i in ${REPOLIST}; do ${PYTHON} ${HOTBACKUP} --archive-type=${ARCHTYPE} ${REPOROOT}${i} ${BACKUPDIR} done - make the backup script executable:\\ # chmod 750 svn-backup.sh - test the script:\\ # ./svn-backup.sh - add the script to ''/etc/crontab'':\\ # # Backup Subversion repositories 45 6 * * * root /root/backup/scripts/svn-backup.sh ===== Reference Links ===== * [[http://www.onlamp.com/pub/a/bsd/2005/05/12/FreeBSD_Basics.html]] - guide to installing/configuring [[http://subversion.tigris.org/|SVN]] on FreeBSD * [[http://svnbook.red-bean.com/]] - the free SVN book * [[http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html]] * [[http://zoneit.free.fr/esvn/]] - a slick GUI client for SVN * [[http://gentoo-wiki.com/HOWTO_Apache2_with_subversion_SVN_and_DAV]] * [[http://svn.collab.net/repos/svn/trunk/INSTALL]] * [[http://httpd.apache.org/docs-2.0/misc/tutorials.html]] * [[http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.backup]] - repository backup information == \\ \\ {{tag>:freebsd}}