Home > backup, scripts, subversion > Script to Backup SVN Repository

Script to Backup SVN Repository

This is a script to backup my svn repositories:

 

#!/bin/bash
# On this script I'm assuming that in the backup path 
# we only have .gz files so I use the same direcotry 
# as temp folder to dump the files there and gzip 
# them later


# Configuration
LOCKFILE=/var/lock/bkp_svn
#repository's names blank space separated
REPO_NAME_LIST="one two website source code"
REPO_PATH="/home/svn/repositories"
BKP_PATH="/backups/svn"
FLAG=0


# Check that there are no running backups
if [ -f $LOCKFILE ]; then
	echo "Instance already running"
	exit 1
fi

# Create the lock file to prevent multiple runs
touch $LOCKFILE

if [ ! -d ${REPO_PATH}/${REPO_NAME} ]; then
	echo "Repository Path: ${REPO_PATH} not found."
	exit 1
fi

# First lets create the dump files
for REPO_NAME in ${REPO_NAME_LIST}
do
	echo "Checking repository: ${REPO_NAME} ..."
	if [ -d ${REPO_PATH}/${REPO_NAME} ]; then
		svnadmin dump -q ${REPO_PATH}/${REPO_NAME} > ${BKP_PATH}/${REPO_NAME}.dump
		echo "${REPO_NAME} dumped."
		FLAG=1
	else
		echo "Repository ${REPO_NAME} not found."
	fi
done

#Now lets create the tar file
if [ ${FLAG} -eq 1 ]; then
	PREFIX_FILENAME=`date +"%y-%m-%d_%H%M"`
	cd ${BKP_PATH}
	tar -zcf ${PREFIX_FILENAME}.tar.gz *dump
	rm *dump
fi

echo "Script Finished"
rm ${LOCKFILE}
exit 0
Advertisements
Categories: backup, scripts, subversion
  1. August 7, 2014 at 1:37 pm

    Hi all, we have just developed web3backup; it’s a PHP script that backs up MySQL, SVN, local files with binary incremental backup, and rotates daily, weekly, monthly and yearly backups. You can get it at:

    http://www.exteon.ro/en/products/programming-tools/web3backup

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: