SVN Backup Script (BASH)

#!/bin/bash

# This is a manual script to backup all SVN repositories in a folder.
# Note that [BakUser] has an RSA key saved on the storage location, so is
# not prompted for password. [BakUser] is access controlled.
# To automate, make cron job, redirect echo to log file, email the log file on completion.
# ToDo: add SVN apache site page to the backup.

START_TIME=$(date +%s)
now=$(date +”%m-%d-%y”)
cd /opt/svn
for project in *
do
echo -ne “dumping ${project}…”
svnadmin dump -q ${project} > /home/[BakUser]/dumps/${project}.dump
echo “done”
done
echo -ne “Zipping…”
cd /home/[BakUser]/dumps
tar -zcf SVN_$now.tar.gz ./* –remove-files
echo “Done”
echo “Uploading…”
scp /home/[BakUser]/dumps/* [BakUser]@[Storage IP]:/srv/proftpd/itshare/ProdBackups/SVN/
echo “Done”
echo -ne “Cleanup…”
rm /home/[BakUser]/dumps/*
echo “Done”
FINISH_TIME=$(date +%s)
ELAPSED_SECONDS=$(expr $FINISH_TIME – $START_TIME)
echo “Time Elapsed: $(expr $ELAPSED_SECONDS / 60)mins $(expr $ELAPSED_SECONDS % 60)secs”

Advertisements


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