The version cleaner module provides commands to remove old or duplicated versions from your version store. Which versions are selected for removal can be configured through voters.
Analyzing and removing unneeded versions can take a lot of time, the version cleanup command can be configured to examine a set number of versions (actually nodes in the version workspace) and then stop. The next run of the version cleanup command will resume from the node last analyzed.
The version cleaner can be configured to select which versions are deleted or retained.
Maven is the easiest way to install the module. Add the following dependency to your bundle:
The module provides a set of commands for removing selected versions from the version history.
Which versions are selected for deletion are configurable through voters. You can define complex conditions to identify if a version should be deleted.
The cleanup commands can be found in the version cleaner catalog:
Remove unneeded versions according to its configuration.
Remove all versions found except root and leaf versions.
|Clean versions from a workspace and path.|
cleanAllVersions work directly on the JCR version workspace. They clean versions from all workspaces with versions.
cleanNodeVersions however cleans versions from a specific workspace and optional path. Unlike cleanVersions and cleanAllVersions,
cleanNodeVersions will not resume its cleaning run after reaching its visitLimit; it doesn't save its progress while cleaning versions.
cleanNodeVersions does not archive versions before deleting them.
The cleanVersions and cleanAllVersions commands can be configured with the following parameters when invoked:
Does a "dry run", going through the selected versions but without deleting or modifying them.
If true, will save an export of each version to be deleted to the specified
NOTE: using this option may generate many files. Be sure you have sufficient space to store the archive versions.
Directory for storing archived versions and cleaning run history.
NOTE: Magnolia must have read and write permissions for the directory.
The maximum number of version nodes that will be checked during a run.
Defaults to 1000 if not specified.
If set to a number less than 0, all version nodes will be checked.
These parameters can also be set as properties in the command configuration, at
The diagnostic commands can be found in the version cleaner catalog:
Locate corrupted versions in the version workspace.
A version is corrupt if it:
The versions selected for removal by the
cleanNodeVersions commands are controlled by Voters. The voters determine if a versions should be deleted (the result of the voting is true) or retained (the result of the voting is false).
You can combine the results of different voters with logical operations (and, or, xor...).
Each command can be configured with the pruneVersions property:
You can use the following voters to identify versions to be deleted or retained:
EligibleVersionVoter returns true if the version is not a root version (the first version of a node) or a leaf version (the last version of a node).
NoModificationVoter returns true if the version has the same modification date as the previous version or false if the modification dates are different.
OldVersionVoter returns true if the version is older than the maxAge threshold or false otherwise.
The age threshold in milliseconds
Defaults to 90 days (i.e. 7776000000)
UnneededVersionVoter returns true if there are at least versionsThreshold newer versions and false otherwise. Use UnneededVersionVoter to limit the total number of versions retained.
The number of versions to be retained
Defaults to 5
- This module is at INCUBATOR level.
- Corrected ordering of version workspace traversal
- Corrected naming for pruning configuration for info.magnolia.services.cleanup.commands.NodeVersionCleanupCommand (pruneVersions → pruneVersion)
- Removed obsolete pruneHistory configuration
- Corrected resumption of pruning from history
- Added cleanNodeVersions command (info.magnolia.services.cleanup.commands.NodeVersionCleanupCommand)