Backup Subversion Repositories And Projects

After I decided to manage my PhD thesis and projects with subversion, the most important thing to consider was a proper backup strategy. I decided to go a bit overboard with it as it might save me some day. There are several ways to backup subversion and I decided to use all of them!

a. Using crontab and rsync to backup subversion

Read my earlier post on crontab if you are not familiar with it. Someday I will write about rsync as well. But for now read this if you are new to rsync. I use the following code to backup the entire subversion repository to my backup directory.

rsync -av --delete --progress /source_directory/subversion/ /destination_directory/backups/subversion_backup/

I used crontab to schedule the above job to run at midnight every day. In case something happens to the original subeversion repository, it is easy to retrieve data from this backup – just copy it to the original location!

b. Using the backup script from COLLABNET (the subversion guys)

The next technique it to use the python based backup script from subversion called hot-backup.py. This script can be used to make a backup of the latest version of the subversion repository. I used the following code to download the latest version from COLLABNET website and install it on my system.

wget http://svn.collab.net/repos/svn/trunk/tools/backup/hot-backup.py.in
mv hot-backup.py.in hot-backup.py

Once that is done, I had to make some configuration changes in the file. The following lines were changed

# Path to svnlook utility
svnlook = r"@SVN_BINDIR@/svnlook"
# Path to svnadmin utility
svnadmin = r"@SVN_BINDIR@/svnadmin"

to look like this

# Path to svnlook utility
svnlook = r"/usr/bin/svnlook"
# Path to svnadmin utility
svnadmin = r"/usr/bin/svnadmin"

The next step is to run the script check if everything is fine. I used the code below:

python hot-backup.py --archive-type=zip --num-backups=10 ~/source_directory/subversion_repository /destination_directory/subversion_backup/

The above code will make a hotcopy of the latest version of the subversion repository into the backup directory in zip format. A total of 10 backups will be maintained at a time, oldest one being deleted when new ones are added.

Once the backup was properly inspected I created a cron job to run this command at midnight every day.

c. Using the subversion ‘hotcopy’ command

This is a very simple technique as it uses the inbuilt ‘hotcopy’ command to backup the svn repository. Follow the command below to make a reliable incremental backup of your svn repositories.

svnadmin hotcopy /source_directory/subversion_repository /destination_directory/subversion_backup/

Create a cron job to schedule it.

Once you have your backup system in place, rest assured that your data are safe.

1 comment to Backup Subversion Repositories And Projects

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>