SVN Module – or, DIY Rollbacks and Backups.

So, earlier this week I committed a prototype of something I have been musing on for DeepThink internally into the OpenSim SVN. It’s a shared region module which acts sort of as a non-realtime datastore. The purpose of which is to allow you to store (and load) region backups to a SVN server.

The SVNModule will use the also-new ‘export’ module, to serialise your region to a collection of XML and binary files that make up your region (XML for anything human editable, ie – object data. Binary for non-human editable components such as terrain data)

It’s worth noting you can use “load-xml2” on the objects.xml file, and “terrain load heightmap.32” to import those parts back into the region from outside the SVN server.

Before I continue, I should point out that this is a very untested module – I have only confirmed it works under Windows 32bit, and has not gone under any sort of sufficient testing for large scale use, yet. Proceed at your own risk.

To setup the module, copy the [SVN] section from OpenSim.ini.example to your OpenSim.ini – make sure ‘enabled = true’ is set, and the other details are in there. At the moment it will only work with svn:// and http[s]:// repositories. I am working on SSL/SSH wrapped repositories at the moment, but it is more difficult to implement, so may take some time. You can use any SVN URL (it doesnt have to be the root of a SVN repository). I recommend that you use one subdirectory per server unless you have a high speed link between all your servers — this is because if all servers share a directory, checkout times will include updates from every directory (something on my agenda to implement a workaround).

Start your sim up, and check to make sure you get [SVNBACKUP]: messages on your console, as long as no errors are thrown (of type SvnException) you should be good. If you see an error – there is help text buried in the exception.

Presuming all has gone well, there are several console commands worth reviewing:

svn save – saves a current copy of all your regions to SVN.
svn load – loads SVN head and imports it to your region.
svn load <revision> – loads a specified revision
svn load-region <name> – loads a specified region at head revision
svn load-region <name> <revision> – loads a specified region from a specified SVN revision.

Automatic backups (periodic saves) and several other features are on the cards, but have not yet been implemented. Ideally I would like to convert this to a datastore-style adapter that imports changes live (so you can rollback individual changes), but that may be unwieldy. Some thought is required on the matter.