Sunday, November 22, 2009

Simple Daily Backup Script for Subversion Repositories

Here's a simple shell script for backing up a Subversion repository on *nix:

#!/bin/sh

# get current date in YYYY-MM-DD format
CURR_DATE=`date +%F`

# define the filename for today's backup, e.g. repo-dumpfile.2009-11-22.gz
FILENAME="/var/backup/svn/repo-dumpfile.${CURR_DATE}.gz"

# set umask so that the file created has permissions of 600
umask 0177

# perform the backup
# note: stderr is being re-directed to /dev/null - you may not want this

/usr/bin/svnadmin dump /var/cm/svn/repo/ 2>/dev/null | gzip > $FILENAME

No comments: