Tuesday, 09 May, 2006

Here's the problem. You've got parents who aren't very good with computers. They use the machine to send e-mails and create documents but above and beyond that they don't really need very much.

Their inexperience with using a computer means that they're liable to destroy their own files occasionally. This wouldn't matter so much if their documents were unimportant but in our case they're actually quite critical.

The question is, how do you back them up? With Subversion of course! In this blog post I'll show you how to set-up Subversion on an Windows XP computer and how to configure your system so that it protects their documents automatically.

The first thing we need to do is download Subversion and install it on the computer. You can do that by visiting:


Once Subversion is installed, the next job is to create a repository. You can do this really easily by opening the command prompt and doing:

SVNADMIN Create file:///c:/Repository

That will create a Subversion repository on at the location c:\Repository. Clearly any user that has read/write access to this folder location will be able to destroy any data recorded to the repository.

To get around this problem on my parent's computer I actually make the repository completely inaccessible from a standard user's account. This has a number of advantages:

  1. If a virus somehow manages to infect the machine from a Limited User account and wipes their data, the virus would not be able to delete the backup copies without performing a privilege escalation attack.
  2. Different users of the machine may not want copies of their files stored in a location that other users of the machine could use. Removing access permissions to the resource mitigates this concern.
  3. If only the Administrator can commit to the repository then the complexity of the backup procedure is much reduced.

What you do next is import all the documents in to the repository. This is done easily with the command line:

SVN Import "c:\documents and settings\JoBlogs\My Documents" file:///c:/Repository/JoBlogs

You can, of course, replace the JoBlogs in the example given above with your own usernames. Once you've got all your user directories imported then next phase is to delete the original copies and check them out again:

rmdir "c:\documents and settings\JoBlogs\My Documents"

SVN CHECKOUT file:///c:/Repository/JoBlogs "c:\documents and settings\JoBlogs\My Documents"

You can now do commits from Jo Blog's My Documents folder.

The next phase is to create a scheduled task that adds and new and changed files to the repository. This doesn't have to overkill; I use a batch file for this task. We don't really care about removing deleted files, since this is a backup system. A more rigorous system might look for files that have been renamed or deleted and reflect these changes too. This is an extra level of complexity that simply isn't required for my fairly modest goals.

cd "c:\documents and settings\JoBlogs\My Documents"

svn add *

svn commit -m "Jo's stuff"

Simply repeat the above lines for each user. You can then set this script to run in the middle of the night and it'll commit everything to the repository. If you're running this so that only the administrator can see the repository

Clearly it's a really smart idea to back-up the repository itself. Otherwise, when the hard-disk eventually goes you'd lose all your data. I have mine set-up to transfer an encrypted gzip archive to an internet server each night. Your plan might be slightly different, but at any rate you're going to want to take a backup of the whole repository from time to time. To do this, run the following command:

svnadmin dump c:\Repository > RepositoryBackup.bak

And that's it really. What is really cool about this is that Subversion will store every copy of the file that has ever existed. If your parent tried to edit their essay and felt like they messed it up, you can undo the damage very easily. If you're storing a lot of text files then you get the full benefits of a version control system. I do quite a lot of edits on HTML pages and LaTex documents so it's pretty nice being able to see the changes between revisions.

So there we go! Happy version controlling.


22:16:51 GMT | #Randomness | Permalink
XML View Previous Posts