Archive for Subversion (SVN)

Securing Subversion (SVN) Under HTTPS with Apache

This configuration is used to set up a svn repository under https for apache.

Contents of vhost file

<VirtualHost *:443>
    ServerAdmin admin@example.com
    ServerName svn.example.com

    SSLEngine on
    SSLCertificateFile /websites/_certs/example.com.crt
    SSLCertificateKeyFile /websites/_certs/example.com.key

    <Location />
        SSLRequireSSL
        DAV svn
        #SVNPath /repositories/repo_name
        SVNParentPath /repositories

        AuthzSVNAccessFile /repositories/svn-access-policy

        AuthType Basic
        AuthName "Restricted Area"
        AuthUserFile /repositories/.htpasswd
        Require valid-user
    </Location>
</VirtualHost>

<VirtualHost *:80>
    ServerName svn.example.com
    RedirectMatch (.*) https://svn.example.com$1
</VirtualHost>

Contents of /repositories/svn-access-policy

[groups]
administrators = user1, user2

[repo_name:/]
@administrators = rw

Comments (1)

Subversion (SVN) Backup BASH Script

This bash script performs an svnadmin hotcopy, tar and gunzips the resulting copy, then transfers the file to a remote server via scp with a datestamped filename.  Enjoy.


#
# http://codingsnippets.com/subversion-svn-backup-bash-script
#
# This script performs an svnadmin hotcopy, tar and
# gunzips the resulting copy, then transfers the file
# to a remote server via scp with a datestamped filename.
#
#
# Please report any comments, bugs or improvements at
# http://codingsnippets.com/subversion-svn-backup-bash-script
# and please leave this message intact so others can
# do the same, improve the script, or download the
# most current version. Thanks.
#

### Change these variables ###

LOCALFILE_PATH="/home/www/backups"
REPO_LOCATION="/repos/myrepo"
TARGET_SCP_LOCATION="username@your.remote.server.com:/home/username/backups/"
TARGET_SCP_PORT="22"
SCP_ID="~/.ssh/id_dsa"

### You don't need to change these ###

FILENAME="repo-`date "+%Y-%m-%d"`.tar.gz"
SCP="$(which scp)"
SVNADMIN="$(which svnadmin)"
TAR="$(which tar)"
TEMP_REPO_DIR="$LOCALFILE_PATH/temp_repo"
RM="$(which rm)"
MKDIR="$(which mkdir)"

### Commands ###

$MKDIR $TEMP_REPO_DIR
$SVNADMIN hotcopy $REPO_LOCATION $TEMP_REPO_DIR
$TAR -cvzf $LOCALFILE_PATH/$FILENAME $TEMP_REPO_DIR
$SCP -i $SCP_ID -P $TARGET_SCP_PORT $LOCALFILE_PATH/$FILENAME $TARGET_SCP_LOCATION/$FILENAME
$RM -rf $TEMP_REPO_DIR
$RM $LOCALFILE_PATH/$FILENAME

Comments