How To Backup PmWiki in Subversion (Code)

By Angsuman Chakraborty, Gaea News Network
Monday, October 8, 2007

PmWiki is a popular wiki software which uses the file system to store wiki pages. We use for our intranet and to document our processes and systems. One of my rising concerns was that it wasn’t backed up at all. So I came up with a simple script to backup pmwiki regularly to our Subversion repository. There are two ways in which this can be done. The ideal way is to automatically add files and commit changes whenever a change is made. The second way is to use a cron job to periodically add new files and commit the changes to the subversion repository. Let’s look at both of the options and explore the simpler one in details.

As mentioned before the ideal solution is to automatically add files and commit changes whenever a change is made. To setup this you need to use Apache to serve the repository through WebDAV interface. Then the WebDAV filesystem has to be mounted on your /var/www/html or htdocs directory (as appropriate). This will allow changes in the wiki (which is effectively adding / changing files under wiki.d directory) to be automated added, as necessary, and commited to your subversion repository. This magic happens because Subversion Apache module supports limited amount, enough for this job, of DeltaAV functionality.

I opted for a simpler solution. First I created a repository and checked in my pmwiki directory. Then I created an update script in the same directory to add new files and commit changes when invoked. I checked in this script too. The code is:


#!/bin/bash
cd /var/www/html/wiki/
svn -q add *
svn -q add wiki.d/*
svn commit -m "Wiki Updates"

This is a very simple script which blindly adds new files and commits changes. Now we just have to invoke it regularly. I invoked “crontab -e” to edit my cron file. Here is the one-liner I use to run the script once an hour:
1 * * * * /var/www/html/wiki/update

Everything is working like a charm.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :