svn backup

Revision as of 19:36, 12 March 2010 by Root (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, 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"