General Geekery

Musings of an incurable technophile

Automatic Version Control of Important Text Files

On my system I have a variety of text files in different locations. I already use version control for source code that I write, but I thought that it would be good also to keep a history of these text files. I wanted to set up a system that could pick the files from their various locations, and join them in one repository that would be automatically updated in a version control system.

Quite some time ago I remembered reading on Cory Doctorow’s blog that he had set up a system for automatic version control of his writing, and that a friend of his had written a series of python scripts called flashbake to accomplish the task.

These scripts are available on github. They are a wrapper on top of git, so they require that git already is installed on the system. For me this was not an issue, since git is the version control tool I use daily.

In order to join the different files in the same directory, I created a new directory, and for each of the files I want to control, added a hard link to the original command using the ln command in the terminal.

The syntax for ln is simple:

ln syntax
1
$ ln /path/to/original_file link_name

What the command does is to create a synonym for the original file. To the operating system the link looks and behaves like a regular file. Changes to the file made in the original location is reflected in the link, and vice-versa.

With all the links created, I created a git repository in the directory and configured flashbake to keep an eye on the files. The flashbake website suggests using cron to run the script, but since I am on OSX, I created a launchd entry instead. Instead of creating a configuration file from scratch, I used the excellent Lingon app from Peter Borg, that makes it very easy to create launchd jobs.

Every 15 minutes flashbake now checks the files for changes, and commits them to the repository without me having to lift a finger. One of the files I back up is my daily todo-list, so now I have an automatic history of the tasks I do every day. As an added bonus flashbake has a plugin system for generating commit messages. There are plugins ranging from adding the current iTunes track to RSS and twitter feeds.

The system requires a little bit of fiddling to set up, but when it is in place, it is completely automatic.

Comments