SCS Computing
 Services and Solutions
  links to the SCS and CMU home pages Carnegie Mellon School of Computer Science Carnegie Mellon University
 
 
 
 » How to… 
 » Accounts & passwords 
 » AFS 
 » AV help 
 » Backups & restores 
 » Calendaring 
 » E-mail 
 » Networking 
 » Printing 
 » Purchasing 
 » Resource management 
 » Security 
 » Software licensing 
 » Support charges 
 » Support lifecycle 
 » Web publishing 
 » Mac support 
 » Linux support 
 » Windows PC support 

Back up your Subversion repositories

SCS Computing Facilities strongly encourages anyone running a Subversion (SVN) server to perform backups of their repositories. The backups performed by the Archival Backup (TiBS) service should not be relied on to provide complete, functional backups of Subversion repositories.

This page describes the usage of svn-fast-backup, a utility designed to perform a complete backup of a Subversion repository.

NOTE: SCS Computing Facilities did not write svn-fast-backup and can make no guarantees about its behavior or be responsible for any data loss as a result of using this tool. We strongly recommend you test restores using the backups created by svn-fast-backup.

Prerequisites

This document is applicable to hosts running one of the following operating systems:

  • Ubuntu 16.04 LTS
  • Ubuntu 14.04 LTS
  • Ubuntu 12.04 LTS (EOL)

In order to use svn-fast-backup, you will need or have:

  • Read access to the location of the Subversion repositories on the Linux computer hosting them
  • Write access to the location that the backup repositories should be stored in

Install svn-fast-backup

If you are using an Ubuntu computer built by SCS Computing Facilities, you can install svn-fast-backup using this command:

sudo apt-get install subversion-tools

Back up a Subversion repository with svn-fast-backup

You can run the svn-fast-backup utility at any time to perform a complete, on-demand backup of a Subversion repository. The svn-fast-backup utility backs up individual repositories. You will need to run svn-fast-backup for each Subversion repository you wish to back up. The general syntax for the command is:

/usr/bin/svn-fast-backup /path/to/repos/ /path/to/backups/

Example: There is a Subversion repository called thesis located in /usr0/repos/. The directory containing the backup repository should be placed in /usr0/backups and this directory must exist before svn-fast-backup is run. The command to use to backup the thesis repository would be:

/usr/bin/svn-fast-backup /usr0/repos/thesis/ /usr0/backups/   

Scheduling backups with svn-fast-backup

You can also have the svn-fast-backup utility run periodically as a cron job. A crontab entry that silently backs up the specified Subversion repository every day at 4:00 AM would look like this:

0 4 * * * /usr/bin/svn-fast-backup -q /usr0/repos/thesis/ /usr0/backups/ > /dev/null 2>&1  

You will need to specify the target location of the existing Subversion repositories as well as the directory that the backup should be located in. If the computer you are running svn-fast-backup on is subscribed to Archival Backup support, you may wish to use a directory in a location backed up by TiBS (like /usr0) to store the backups created by svn-fast-backup.

By default, the svn-fast-backup tool will keep 64 backups of each repository; older backups will be deleted. You will want to consider the size of each backup and the amount of free disk space on your machine. If keeping 64 backups of each repository would be unfeasible, you can use the "--keep" switch documented in the man page for svn-fast-backup to reduce the number of backups that are preserved.

Restore a Subversion repository backed up with svn-fast-backup

Backups performed using svn-fast-backup are full copies of the repository including configuration files, all hooks and database files. Restoring a repository backup to an alternate location is a simple matter of moving the directory containing the backup to the desired location. The backup repository can be moved to the original location (if the original repository is missing) or to an alternate location. While users can checkout directly from the repository backup, it is recommended that the backup repository be moved or copied prior to use (in order to maintain a copy of the backup).

Example: The example thesis repository was at revision number 14 when the backup was performed. The resulting backup repository was /usr0/backups/thesis-14/. The thesis-14 directory can be moved in to /usr0/repos/. This will not overwrite the existing repository in the /usr0/repos/thesis directory.

mv /usr0/backups/thesis-14 /usr0/repos/
ls /usr0/repos/
thesis thesis-14

Both the original and backup repository now co-exist and users can check out from either:

svn co file:///usr0/repos/thesis
svn co file:///usr0/repos/thesis-14

Notes

Like standard repositories, backup repositories created using svn-fast-backup will be forwards compatible. For example, if a backup repository was created on a machine running Subversion 1.8.8, the backup repository should just work on a machine running Subversion 1.9.3.

By default, the svn-fast-backup tool will keep 64 backups of each repository; older backups will be deleted. The number of preserved backups can be increased or reduced using the "--keep" switch documented in the man page for svn-fast-backup.

The svn-fast-backup tool is designed for Subversion repositories that use FSFS as their data store. This has been the default behavior since Subversion 1.2, which was originally released in 2005.

Related Documentation

svn-fast-backup man page
Ubuntu svn-fast-backup man page