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
- How pages are stored
- What “remove old revisions” means
- Manual method
- MoinMoin Wiki method
- 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
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″
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.
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).
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-.tar.gz” and the it will remove old revisions.