Versions cleaner icon
Module Id
versions-cleaner
Group Id
org.jahia.community
Updated
Requires Jahia
8.2.0.0
Author
Florent BOURASSE
Category
Tools and Utilities
Status
COMMUNITY info

Versions cleaner group_work

Jahia module to clean versions by:

  • keeping the last N versions
  • removing the orphaned versions

Dependencies & Dependants

Dependencies
  • NONE
Dependants
  • NONE

Changelog 2.3.0

FAQ

How to use?

 

You can run some purge on demand, using a Karaf command or configure some automated purges.

Background job

Properties:

Name Default value Description
jahia.versions.cleaner.job.disabled true Disable the scheduled purge
jahia.versions.cleaner.job.reindexDefaultWorkspace false Reindex default workspace before cleaning
jahia.versions.cleaner.job.checkIntegrity false Check integrity of the versions
jahia.versions.cleaner.job.nbVersionsToKeep 2 Number of versions to keep
jahia.versions.cleaner.job.maxExecutionTimeInMs 60000 Max execution time in ms (0 = Infinite)
jahia.versions.cleaner.job.deleteOrphanedVersions false Delete orphaned versions
jahia.versions.cleaner.job.cronExpression 0 30 1 * * ? Crontab expression for the job

Commands

versions-cleaner:run

Run a scan the versions tree, and perform the configured actions

Options:

Name alias Multiple Default value Description
-r --reindex-default-workspace   false If specified, reindex the default workspace before cleaning
-c --check-integrity   false If specified, check the integrity of the versions
-n --nb-versions-to-keep   -1 Number of versions to keep on the non orphaned histories
A negative value means that the non orphaned histories are ignored
-t --max-execution-time-in-ms   0 Max execution time in ms (0 Infinite)
-o --delete-orphaned-versions   false If specified, the orphaned versions are deleted. They are ignored otherwise
-p --subtree-path     Subtree of the versions tree where to run the scan. If not defined, the whole tree is processed
-pause     0 Duration of the pause between 2 version deletions. No pause if less or equal to zero
-skip --skip-subtree x   Path to be skipped by the process
Useful for example if you have identified some version histories which are particularly massive, and you want to iterate over the rest first
Several paths can be defined
-threshold-long-history-purge-strategy     1000 Number of versions over which orphaned histories are purged by deleting the versions one by one, to reduce the memory footprint
-force-restart-from-the-beginning     false If specified, the process will restart from the beginning of the tree
Otherwise, it will try to restart from where the previous execution had stopped

Examples:

Reduce all the non-orphan histories, keeping maximum 2 versions per history:

versions-cleaner:run -n 2

Delete all the orphan histories:

versions-cleaner:run -o

Reduce all the non-orphan histories, keeping maximum 2 versions per history, and delete all the orphan histories, at the same time:

versions-cleaner:run -n 2 -o

Same command, but with a time limit. If the process has not reached the end of the tree after 10mn of execution, it will stop gracefully. The next execution will restart from the reached position.

versions-cleaner:run -n 2 -o -t 600000

How to interrupt an execution?

The module defines a predefined script (stopVersionPurgeProcess.groovy) for the Extended Groovy Console

Otherwise, run the below code in a Groovy console.
In case of a Jahia Cluster, this has to be executed on the JVM where the purge is running. If you have triggered it with the Karaf command, this means the same server. If you use the scheduled background execution, this means the procesing server.

System.setProperty("versions-cleaner.interrupt", "true")

How To Install

  • In Jahia, go to "Administration --> Server settings --> System components --> Modules"
  • Upload the JAR versions-cleaner-X.X.X.jar
  • Check that the module is started

License

MIT License

Copyright (c) 2022 - present Florent BOURASSÉ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.