web analytics

Script to backup svn repo and copy to backup server

A small script which will be helpful for developers, it will take the svn backup on a daily basis. Now you can simple restore this backup to start working with it in another server.

#!/bin/sh

TO=”abc@xyz.com”
CC=”def@xyz.com”
SUBJECT=” SVN backup done”
SUCCESS_MSG=”SVN dump has been copied successfully”
ERROR_MSG=”SVN dump error”
ERROR_SUBJECT=”URGENT – SVN dump error”
svn_output_file=/root/scripts/svn_error
rsync_output_file=/root/scripts/rsync_svn_error

### Suppose name of the repository is myrepo which resides at /var/www/svn/myrepo###
cd /var/www/svn
svnadmin dump myrepo > myrepo.dump  2>$svn_output_file
if  [ $? -eq 0 ]
then
rsync -avzrp myrepo.dump user@xxx.xxx.xxx.xxx:/data/rsync_backups/svn_dump/  1>$rsync_output_file
if [ $? -eq 0 ]
then
cat $svn_output_file | /bin/mail -s “$SUBJECT” “$TO” “$CC”
else
cat $rsync_output_file | /bin/mail -s “$ERROR_SUBJECT” “$TO” “$CC”
fi
else
cat $svn_output_file | /bin/mail -s “$ERROR_SUBJECT” “$TO” “$CC”
fi

One comment to Script to backup svn repo and copy to backup server

  • max  says:

    Your place is actually valueble for me. Thanks!…

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>