Automatically back up a subversion repository to GMail

| | Comments (0) | TrackBacks (0)

This is a little script I wrote to be used as a subversion post-commit hook. It automatically emails an encrypted archive of the repository after every commit, so you don't have to worry too much about the subversion server exploding.

#!/bin/sh

# Configuration #
REPODIR=/var/svn # where your repositories live
#export HOME=/home/jason
    # set this to your home directory if the hook
    # doesn't run as you, and therefore cannot find
    # your GPG keys...
EMAIL="example+backups@gmail.com" # where to send the backups
GPGID="12345678" # gpg key id to use for encrypting

REPO="$1"
REV="$2"

echo "Running gmail-backup-svn $REPO $REV"
R=`echo $REPO | sed s,$REPODIR,,`
(
    echo "From: $EMAIL"
    echo "To: $EMAIL"
    echo "Subject: [SVN-BACKUP] $R"
    echo ""
    if [ -n "$REV" ]then echo "Revision: $REV"fi
    for I in `seq 1 40`do echo ""done
    /usr/bin/svnadmin dump $REPO \
    | /bin/gzip -c - \
    | /usr/bin/gpg --armor --trust-model=always --recipient $GPGID --encrypt
) | /usr/sbin/sendmail -oi -oem -odq $EMAIL

0 TrackBacks

Listed below are links to blogs that reference this entry: Automatically back up a subversion repository to GMail.

TrackBack URL for this entry: http://www.jasonkohles.com/mt/mt-tb.cgi/1

Leave a comment

About this Entry

This page contains a single entry by Jason Kohles published on April 7, 2008 8:40 PM.

Movable Type Plugin for Text::Multi is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Pages

Creative Commons License
This weblog is licensed under a Creative Commons License.