Mon Apr 30 18:38:00 UTC 2007
Backing up a Subversion Repository
The simplest way to back up a Subversion repository is to make a full backup of it. If your repository is very large, then this may be a bit of a slow process and there are other ways which can be used. However, if you are just looking for the simplest way to ensure that you have a simple backup of your precious repository, then the instructions are very simple!
Backing up
Especially if you use the BDB backend, it is important that you do not access or copy the repository directly. If someone accesses the repository for anything at this time, your backup will be corrupted and quite useless. Therefore, you need to use hotcopy option of the svnadmin command. This ensures that you get a proper comprehensive snapshot irrespective of people accessing the repository at the same time.
More importantly, though, there is a simple Python script called hot-backup that takes as inputs the path of the repository and the path of the backup directory and does the rest. If you have Python installed, this is the easiest way.
- Download the script
- Change the name to hot-backup.py
- Open it in a text editor and change the first line to the directory where Python is installed. In my case, this is
#!C:\Python24 - Update the paths to ‘svnlook’ and ‘svnadmin’ further down in the script. In my case, these were changed to:
svnlook = "C:/DevSupport/Subversion/bin/svnlook"andsvnadmin = "C:/DevSupport/Subversion/bin/svnadmin". - Save the script to a directory of your choice. I saved it to: c:\DevSupport\SubVersion\tools\backup
- Run it from the command line giving it the repository and backup paths.
D:\Repository>c:\DevSupport\Subversion\tools\backup\hot-backup.py D:\Repository\svn\Project D:\Repository\backup
After you run this, in the backup directory, you will see a new directory created having the same name and revision number as the project name and version it backed up. For example, you may get something like Project00-4 which means that this is revision 4 of Project00.
Restoring
The copy that is made is a copy of the entire repository and is actually a fully working repository and can be used just like any other repository. There is no special procedure to restore a backup.
Links
This topic has been written about quite a bit and you will find quite a bit if you search Google.
- Refer to Repository Management in the ‘official’ SVN book for more details.
- This article helped me get started (I just made minor modifications to get it working on Windows)
- Finally, this article talks about the dump and load commands that can also be used for backing up, migrating and restoring repositories.
Kinnego du Monde said,
June 30th, 2008 at 07:49 AM
Great instructions on how to use the Python back up script – I needed this in a hurry and you delivered the goods. Very much appreciated.
Mohit said,
August 2nd, 2008 at 05:59 PM
Glad it helps :)
Cheers Mohit.