Linux: How to remove old revisions in MoinMoin Wiki

MoinMoin Wiki is a nice, easy to use WikiEngine written in python. Pages (all revisions) and attachment are stored on the file system. In some cases keeping all revisions of a page can be a waste of disk space. In this cases we need a way remove old revisions.


Table Of Contents

  1. How pages are stored
  2. What “remove old revisions” means
  3. Manual method
  4. MoinMoin Wiki method
  5. Using a script

How pages are stored

I’ve used only MoinMoin Wiki version 1.7.2 so I’ll analyze the directories structure of this version.

Let’s say your MoinMoin Wiki instance is located in “/home/user/wiki” directory. In this case your pages are stored in “/home/user/wiki/data/pages”. For each page you have a directory: for a page called “Test” you will have directory “/home/user/wiki/data/pages/Test”.

Each page directory has the following structure:

  • current: text file that contains the current (the latest) revision (ex: 00000001)
  • revisions: a directory containing all revisions as text files named 00000001, 00000002 and so on. The latest revision is the one with the bigger number.
  • attachments: a directory containing page attachments
  • edit-log: log of all modifications on this page and it’s attachments
  • cache: a directory for internal usage

Top

What “remove old revisions” means

If pages are stored as described here, remove old revisions means that for each page’s directory you have to:

  • remove “edit-log” file
  • set the content of the file “current” to “00000001″
  • move the latest version to “revisions/00000001″
  • remove all revision files other then “00000001″

Top

Manual method

See What “remove old revisions” means section to know all you have to do manually. This method can be used if you want to remove the revisions only for few pages.

Top

MoinMoin Wiki method

MoinMoin Wiki has a tool called “moin”. With this tool you can “reduce” the wiki into another folder.

If your wiki instance is located in “/home/user/wiki” directory you have to execute the commands:

moin --config-dir=/home/user/wiki  maint reducewiki --target-dir=/home/user/new_wiki
rm -rf /home/user/wiki/data/pages
mv /home/user/new_wiki/pages /home/user/wiki/data/
rm -rf /home/user/new_wiki

There is only one problem with this method (at least on version 1.7.2): the new pages directory will contains all pages including internal ones (example: MoinMoin Wiki help pages).

Top

Using a script

ATTENTION: USE IT AT YOUR OWN RISK !!!

This method means doing all we have to do in manual method using this script: reduce_moinmoin.sh.

 

If your wiki instance is located in “/home/user/wiki” you have to execute:

sh reduce_moinmoin.sh /home/user/wiki/data/pages

This script will backup your pages in a file called “moinmoin-pages-<data>.tar.gz” and the it will remove old revisions.

Top

Tags: , ,

3 Responses to “Linux: How to remove old revisions in MoinMoin Wiki”

  1. TheClayman Says:

    On my system (Ubuntu 7.10) the script reports due to an “unknown operator”. Changing
    if [ $firstrevision. == $lastrevision. ]; then
    to
    if [ $firstrevision. = $lastrevision. ]; then
    helps. Besides that the script worked for me, Thanks.

  2. dan Says:

    Fixed. Thanks

  3. Personal Wikis are Totally Awesome - Page 2 - openSUSE Forums Says:

    [...] Well, I put tmp in a tmpfs, so that’s no longer an issue. Also found this little script… Linux: How to remove old revisions in MoinMoin Wiki | le-Web.org Which is handy if you don’t have the binary tools installed, and are just running it as a python [...]

Leave a Reply