Showing posts with label Purge Version. Show all posts
Showing posts with label Purge Version. Show all posts

May 10, 2020
Estimated Post Reading Time ~

Version Purging in AEM

In a standard installation, AEM creates a new version of a page or node whenever you activate a page (after updating the content). You can also create additional versions on request using the Versioning tab of the sidekick. All these versions are stored in the repository and can be restored if required.

These versions are never purged, so the repository size will grow over time and therefore need to be managed.

AEM is shipped with various mechanisms to help you manage your repository:
the Version Manager
This can be configured to purge old versions when new versions are created.
the Purge Versions tool
This is used as part of monitoring and maintaining your repository.
It allows you to intervene to remove old versions of a node, or a hierarchy of nodes, according to these parameters:
  • The maximum number of versions to be kept in the repository. When this number is exceeded, the oldest version is removed.
  • The maximum age of any version kept in the repository. When the age of a version exceeds this value, it is purged from the repository.
Version Manager
In addition to explicit purging by means of the purge tool, the Version Manager can be configured to purge old versions when new versions are created.

To configure the Version Manager, create a configuration for:
PID com.day.cq.wcm.core.impl.VersionManagerImpl

Purge Versions Tool
The Purge Versions tool is intended for purging the versions of a node or a hierarchy of nodes in your repository. Its primary purpose is to help you reduce the size of your repository by removing old versions of your nodes.
http://localhost:4502/etc/versioning/purge.html


By aem4beginner

April 23, 2020
Estimated Post Reading Time ~

AEM Interpretation of Version purging results

Analyzing the Console
The Dry Run and Purge processes list all the nodes that have been processed. During the process, a node can have one of the following states:

  • ignore (not versionable): the node does not support versioning and is ignored during the process.
  • ignore (no version): the node does not have any version and is ignored during the process.
  • retained: the node is not purged.
  • purged: the node is purged.
Moreover, the console provides useful information about the versions:
  • V 1.0: the version number.
  • V 1.0.1*: the star indicates that the version is the current one.
  • Thu Mar 15 2012 08:37:32 GMT+0100: the date of the version.

In the above screenshot example:
  • The Shirts versions are purged because their version age is greater than 2 days.
  • The Tonga Fashions! versions are purged because their number of versions is greater than 5.


By aem4beginner

AEM How to Purge Versions of a Web Site

Solution:
To purge versions of a web site, proceed as follows:
  • Navigate to the Tools console http://localhost:4502/misccadmin# and select Versioning and double-click Purge Versions.
  • Set the start path of the content to be purged (e.g. /content/geometrixx-outdoors). a. If you want to only purge the node defined by your path, unselect Recursively.
  • b. If you want to purge the node defined by your path and its descendants select Recursively.
  • Set the maximum number of versions (for each node) that you want to keep. Leave empty to not use this setting.
  • Set the maximum version age in days (for each node) that you want to keep. Leave empty to not use this setting.
  • Click Dry Run to preview what the purge process would do.
  • Click Purge to launch the process.
Caution:
Purged nodes can not be reverted without restoring the repository. You should take care of your configuration, so we recommend you to always perform a dry run before purging.


By aem4beginner

AEM Version Purging Basics

The Purge Version tool is intended for purging the versions of a node or a hierarchy of nodes in your repository.
Its primary purpose is to help you reduce the size of your repository by removing old versions of your nodes.

Overview
The Purge Versions tool is available in the Tools console under Versioning or directly at: http://localhost:4502/etc/versioning/purge.html



Start Path
  • An absolute path on which the purge must be done.
  • You can select the Start Path by clicking the repository tree navigator.
Recursive
  • When purging data you can choose between performing the operation on one node or on a whole hierarchy by selecting Recursive.
  • In the last case the given path defines the root node of the hierarchy.
Maximum versions to keep
  • The maximum number of versions to be kept for a node.
  • When these number exceeds this value, the oldest versions are purged.
Maximum version age
  • The maximum age of the version of a node.
  • When the age of a version exceeds this value, it is purged.
Dry Run
  • Because removing versions of your content is definite and can not be reverted without restoring a backup,
  • thePurge Versions tool provides a dry run mode that allows you to preview the purged versions.
  • To launch a dry run of the purge process, click Dry Run.
Purge
  • Launch the purge of the versions on the node defined by the Start Path.


By aem4beginner

April 1, 2020
Estimated Post Reading Time ~

How to remove version history in CQ / AEM

Problem:
Over time the Version store /jcr:system/jcr:versionStorage can grow to a considerable size. You see that when:
lots of tar files in (CQ5.3):
/crx-quickstart/repository/version/copy
/crx-quickstart/repository/shared/version
large lucene index on:
/crx-quickstart/repository/repository/index

This is also helpful when you are upgrading from CQ5.2X to the latest version (As version purging was not enabled in the previous version)

Solution: There are a couple of solution to this,
You could enable automatic version purging. See more information here
You can also remove the version using the code mention below.

version purging
Do not use this code without this fix: https://issues.apache.org/jira/browse/JCR-2613 (fixed starting CRX 2.2)

Session session = resource.getResourceResolver().adaptTo(Session.class);
QueryManager qm = session.getWorkspace().getQueryManager();

String xpath = "";

xpath = "//element(*,nt:frozenNode)[jcr:like(cq:parentPath, '<some-path>%')]";

QueryResult result = qm.createQuery(xpath, javax.jcr.query.Query.XPATH).execute();
NodeIterator iter = result.getNodes();
Node node = null;

while (iter.hasNext()) {
node = iter.nextNode();
String path = node.getPath();
VersionManager mgr = session.getWorkspace().getVersionManager();

// get version history
VersionHistory vh = (VersionHistory) node.getParent().getParent();
// VersionHistory vh = mgr.getVersionHistory(path);
String id = vh.getIdentifier();

// get the names of the versions
List<String> names = new LinkedList<String>();
VersionIterator vit = vh.getAllVersions();
while (vit.hasNext()) {
Version v = vit.nextVersion();
if (!v.getName().equals("jcr:rootVersion")) {
names.add(v.getName());
}
}

// remove all versions
for (String name: names) {
vh.removeVersion(name);
}
}
session.logout();


By aem4beginner