Powered by XP-Dev.com - Agile Software Development Tools | You are currently not logged in. Login Now | Don't have a XP-Dev.com account ? Create one for FREE

XP-Dev.com

Provides Enterprise Grade Hosting for Git, Subversion, Trac and Agile Project Tracking Tools

Making Your Own Subversion Backups

Profile+Picture rs on Mon 18 May, 2009 03: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 7 comments


Profile+Picture bbgpsgolf

Fri 29 May, 2009

Here there a way to create this as a cron task to run once a day/week?

Also do you just create different svnadmin folders to the differnet subversions you have permission to?

Profile+Picture rs

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.

Profile+Picture bonelifer

Mon 01 Jun, 2009

I’m trying to get this setup, but I’m running into a problem with the initialization. I’m on Windows XP, run VisualSVN Server(http://www.visualsvn.com/server/) locally, which consist of(from the readme file):

- Subversion 1.6.2
- Apache 2.2.9
- OpenSSL 0.9.8k
- ZLib 1.2.3
- Neon 0.28.4

The line I’m running is:
svnsync init file://c:/Repositories/xpdevcopy http://svn2.xp-dev.com/svn/bonelifer-forum/

I get this error:
svnsync: Unable to open an ra_local session to URL
svnsync: Unable to open repository 'file://c:/Repositories/xpdevcopy'

The repository link is correct as it opens in Windows to the right folder

I’m not sure what’s going on.

Profile+Picture bonelifer

Mon 01 Jun, 2009

Okay I think I may have figured out what I needed to change.

Here’s my initilization line:

svnsync init https://jeanna:8443/svn/xpdevcopy/ http://svn2.xp-dev.com/svn/bonelifer-forum/

Here’s the sync line:
svnsync sync https://jeanna:8443/svn/xpdevcopy/

Just have to remember to use the HTTPS url that VisualSVN Server uses.

I wonder if you could confirm this is right just to make sure.

Profile+Picture bonelifer

Mon 01 Jun, 2009

Never mind I re-read the entire post and found what I missed. I assume though that I should set my local copy read-only.

OK, I’ve figured it out for myself. Obviously it has to able to be written too. I wasn’t thinking very well when I asked that. For those using using VisualSVN server(locally), also note that when you first initialize that it will tell you that the servers SSL cert is self-signed, just tell it to permanently remember this cert is good.

Profile+Picture sjwood140263

Sun 07 Jun, 2009

Using SubVersion 1.5.6 on XP, I needed an extra slash in the file arguments, thus

file:///

Profile+Picture rs

Mon 08 Jun, 2009

Thanks sjwood140263. I’ved fixed the windows paths

You do not have sufficient permissions to comment

Rss Blog Entry and Comments