Keep last 5 versions

I would like to keep last “n” versions of a document. Is there any setting to do this? Kindly point me to the right documentation.

  • Dominic

There is nothing like this out of the box no. It would not be very hard to implement a listener which clean old versions when a document is saved.

Hi, AFAIK this is not a feature that exists and it’s not been developed on purpose so that no data is lost. Now, there are DB tables holding revision data and you could remove some rows in these tables but you’d need to be very careful and understand the DB schema well. Another safer option is to use XWiki APIs to delete revisions (slower but safer) by writing some scripts. Some example here: https://snippets.xwiki.org/xwiki/bin/view/Extension/Delete%20Revisions%20From%20Author

I need some basic help as I am not familiar/comfortable with this Velocity scripting.
Hope my requirement is much simpler. List all the documents available in the repository and further check each document versions. Keep the latest n revisions and delete the rest. Appreciate any help here.

There are many updates happened in xWiki in the last one year. Is it possible to take this as a parameter in a configuration? This will reduce the space and load on the database.
Has any one implemented this by writing any external scripts etc?

I am using LTS (std flavor version) 11.10.10 with HSQLDB-Jetty.

Best
Dominic

Dominic, I assume you are aware of this page:

and the warnings within. If performance is the issue, you might consider migrating to another database (if the DB is the restricting factor). Deleting the last n versions is a very dangerous method IMHO, except you have a very dedicated use case of your wiki …

Thank you Beat. After this email post, first I moved my DB from HDQLDB to one of our existing MariaDB instance. Moved my xWiki to a tomcat setup.

Deleting the last n versions is a very dangerous method IMHO, except you have a very dedicated use case of your wiki …

I have few documents with 160+ versions. I am using xWiki for a very small team and last 5 versions would server our purpose and through removing other versions would free up space :slight_smile:.

Great news. Hope that improved the situation somewhat. You can still manually delete a range of versions of a document or write a macro to do that or Java code to do so (never did Java though, since this would need to be “installed” on the server … I prefer something that is available through the web as of KISS…). You can use the xWiki scheduler to trigger the macro or your Java bit if you don’t want to implement this the professional way that @tmortagne mentioned. I assume it is only for a branch or few documents, right?