User Tools

Site Tools


scm:svn:backup

SVN Backup & Restore

Daily Repository backups

Subversion comes with a handy backup script called hot-backup.py. For backing up a whole directory of repositories a simple bash script can be used and called daily from cron_jobs.

See this sample bash script to get an idea:

#!/bin/bash
 
## script for daily Subversion backups
## Nik Wolfgramm, April 2010
 
# Path settings
svnbasedir="/srv/svn/repos/"
svnfullbkdir="/srv/svn/backups/"
hotbackuppath="/srv/svn/scripts/hot-backup.py"
 
# hot-backup options
archivetype="bz2"
numbackups="10"
 
# create the date string
date="$(date +%Y-%m)"
 
echo "+++ Backing up subversion repositories..."
 
for repo in $(ls $svnbasedir) ; do
 $hotbackuppath --archive-type=${archivetype} --num-backups=${numbackups} ${svnbasedir}${repo} ${svnfullbkdir}
  if [ "$?" != "0" ]; then
    echo "!! Hot backup failed on repository: ${repo}"
  else
    echo "++ Successfully backed up repository: ${repo}"
  fi
done

Restore a Repository from a svn dump file

rm -rf /var/svn/repos/example
svnadmin create /var/svn/repos/example
svnadmin load /var/svn/repos/example < /var/svn/backups/example
chown -R apache:apache /var/svn/repos/example

Upgrade Repositories after a application migration

Upgrade a repo (ie 1.4 ⇒ 1.5)

svnadmin upgrade /var/svn/repos/example
/srv/wiki.niwos.com/data/pages/scm/svn/backup.txt · Last modified: 2010/04/13 13:30 (external edit)