svn backup

Jump to navigationJump to search

# This creates a backup of an SVN repository. This should be run
# on the repository side. After that completes a separate process
# should be run on the remote backup server side. The remote backup 
# server should pull the backup file by running the following command:
#     rsync -avz .

if [ -r svn_backup.tar.gz ] ; then
    mv -f svn_backup.tar.gz svn_backup-previous.tar.gz
svnadmin hotcopy /home/svn/ /home/svn/svn_backup.tar.gz
(cd /home/svn/ && tar -svn_backup.tar svn_backup)
gzip --rsyncable /home/svn/svn_backup.tar
chgrp backup /home/svn/svn_backup.tar.gz
rm -rf /home/svn/svn_backup

On the remote backup server side a cron job should be run that does this:

su backup -c "rsync -avz /var/backups/svn_backup.tar.gz"