Making Your Own Subversion Backups

Posted by rs picture rs on Mon 18 May, 2009 04:35:59 +0000

Since the recent changes in accounts, subversion repositories for Free accounts are no longer backed up.

Now, before you Free users out there start getting nervous and/or panicking, there is a quick backup solution following the D.I.Y. principle.

Sync 'em up

Subversion provide some really good tools in its arsenal for free. One of them is called svnsync which aids in taking away all the headache of keeping a full copy of a repository (including its changes and revision history!). The best part of svnsync is in its ease of use (albeit with some initial setup learning curve):

Create a local repository

First, we need to create a local repository that will be our copy of the subversion repository on XP-Dev.com:

svnadmin create xpdevcopy

Add a pre-revprop-change hook

Next (this is mandatory) you will need to add a pre revision property change hook, which will allow svnsync to put in some of its own variables to do its magic.

Unix users can perform the following:

cat <<'EOF' > xpdevcopy/hooks/pre-revprop-change
#!/bin/sh
exit 0
EOF
#Dont forget to set the execution flag
chmod +x xpdevcopy/hooks/pre-revprop-change

Windows users, an empty hook script (basically an empty file) should be installed in xpdevcopy\hooks\pre-revprop-change.bat

Initialise the copy

You’ll need to initialise the copy repository, and this only has to be done once. Svnsync adds some of its own variables in the copy repository in this step.

Do remember to replace http://svn.xp-dev.com/svn/myrepository with the location of your XP-Dev.com repository in the following commands

Unix users:

svnsync init file://`pwd`/xpdevcopy http://svn.xp-dev.com/svn/myrepository

Windows users (do remember to replace c:/path/to/xpdevcopy with the full path of your repository):

svnsync init file:///c:/path/to/xpdevcopy http://svn.xp-dev.com/svn/myrepository

Start syncing

Syncing is when svnsync starts downloading all the various revisions and stores them in your copy:

For Unix systems:

svnsync sync file://`pwd`/xpdevcopy

Or Windows:

svnsync sync file:///c:/path/to/xpdevcopy

And that’s it. The next time you want to re-sync your local copy of the repository, all you need to do is execute the last step above, i.e. svnsync sync file://path/to/xpdevcopy

Integration with XP-Dev.com Webhooks

Now, if you’re really into your scripts and would love to have a real-time backup for your repository, all you have to do is install a Post Commit Webhook on your XP-Dev.com subversion repository and get your receiver web script to perform the svnsync sync file://path/to/xpdevcopy process above.

Of course, you could just upgrade to a Pro account and get the real-time backups out of the box.

View 2 comments

Comments

rs picture

rs on Sat 30 May, 2009

@bbgpsgolf using it with cron is pretty easy and doable. There’s a simple introduction article that can help you out.

If I’m not mistaken you should create one folder for each repository. I haven’t tried “joining” repositories into one. While theoretically it might be possible, having them distinct is usually good practice.

 
rs picture

rs on Mon 08 Jun, 2009

Thanks sjwood140263. I’ved fixed the windows paths

 

You do not have sufficient permissions to comment

Blog Entry Options

Blog Options

Blog Archives

Feeds

Blog Entry and Comments