Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Older version package uninstallation

Avatar

Level 3

Hi,

I am trying to delete all the older version of code packages installed in Author/Publishers and specifically trying to delete packages under /etc/packages with package name "cq-ui-5.1.45-SNAPSHOT.zip"..

 

"cq-ui-5.1.45-SNAPSHOT.zip" is the latest version installed on the system and we have similar old package versions 

"cq-ui-5.1.44-SNAPSHOT.zip";

""cq-ui-5.1.43-SNAPSHOT.zip""; 

"cq-ui-5.1.42-SNAPSHOT.zip" etc...

and this version starts from the year 2016 with package name"cq-ui-5.0.00-SNAPSHOT.zip" .

 

The problem here is, all these packages are NOT under any group & these packages are not installed as a separate packages.  

When i select the latest package "cq-ui-5.1.45-SNAPSHOT.zip" and then click "Older Versions"(below screenshot refers old versions) and i could see all these older version packages are under the same package since 2016. Now the concern is, these packages are not installed separately and all the old version packages from 2016 are under one package. 

 

I have run the below command to uninstall one older version package alone and it shows uninstalled successfully. But when i check in package manager, i don't see any changes

curl -u admin:admin -F cmd=uninstall http://localhost:41001/crx/packmgr/service/.json/etc/packages/cq-ui-5.1.43-SNAPSHOT.zip
{"success":true,"msg":"Package uninstalled"}

 

After i executed uninstall command on "cq-ui-5.1.43-SNAPSHOT.zip", listed the package but it doesn't show as any modification made.

<package>
<group></group>
<name>cq-ui</name>
<version>5.1.43-SNAPSHOT</version>
<downloadName>cq-ui-5.1.43-SNAPSHOT.zip</downloadName>
<size>30834408</size>
<created>Thu, 26 Mar 2020 17:03:18 -0400</created>
<createdBy>admin</createdBy>
<lastModified>Thu, 5 Mar 2020 15:45:48 -0500</lastModified>
<lastModifiedBy>admin</lastModifiedBy>
<lastUnpacked></lastUnpacked>
<lastUnpackedBy>null</lastUnpackedBy>
</package>

 

Does it mean - this package is successfully uninstalled? If this is not right - How do i uninstall/delete these older version packages without restoring? Kindly assist.

 

CQ.png

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello,

I've actually written a script that does this, you can find it here: https://github.com/theopendle/aem-purge-packages

Packages are stored in the JCR like any other node. You can find them all under /etc/packages. For example, here are multiple versions of AEM Core Components on my instance:

Selection_121.png

 

For every package on your system, my script will keep only the most recent version and delete (no uninstall) all the others. 

If you run the script, it will first analyse your packages and tell you 

  • How many outdated packages are to be deleted
  • How much space it will save

You can then choose to continue or not:

$ python3 aem-purge-packages.py
Namespace(date=None, force=False, host=None, path=None, user=None, verbose=False)
Getting package list from AEM ...
Done
913 packages found
110 outdated packages found
Getting package list from AEM ...
Done
Purging outdated packages will remove 1.49 GB / 4.31 GB of package data
Do you wish to continue? (y/n):

 

In my case, I chose to continue, and you can see that it removed the older versions of each package:

Selection_117.png

Run the script with the -f flag to prevent it from asking for confirmation for every single deletion. Run it with the -h flag to see more options.

 

However please BEWARE!

  1. I recommend that you back up your system before making any kind of large automated purges as a general rule of thumb, including this script.
  2. There is a dependency system for packages. Future packages (including official Adobe ones) might have references to older packages that my script would purge (not the case on my instance, but if you have a old instance that was upgraded many times, it could happen). For example, here are the dependencies for the latest ACS Commons content package:
    Selection_118.png 
    If I delete a dependency, here is what happens:
    Selection_119.png
    This is a sort of "false positive" because the dependency package is gone, but the content of the package had already been installed, so everything works fine. 

If you want to improve my script to exclude packages from the purge if they are dependencies of other packages, you are more than welcome!

View solution in original post

9 Replies

Avatar

Community Advisor

There's no need for a comprehensive approach when you can manage the removal of packages under http://localhost:4502/miscadmin#/etc/packages

Make sure you are logged in with the right privileges.

If you don't have any release notes bounded to versions of the Artifact-Zip AEM content packages, then it will be difficult to understand if you have any breaking changes. Typically an AEM project, the latest content package contains incremental deployments of the version before it. If so, It can be safe to remove the older packages manually.

A manual approach can be done in http://localhost:4502/miscadmin#/etc/packages for each instance. Simply right-click and delete the old packages. And you would not need to uninstall the packages, but to "DELETE" the packages.

However, if you wish to automate deleting packages using CURL commands, like you already started, click here to validate the command https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/curl.html

Avatar

Level 3

Hi Brian,

Thanks for the response. But the problem here is, i am unable to see the old packages as a separate package.

As mentioned earlier, all old packages are underneath the latest package and i don't see an uninstall option on the old package versions instead i see only "Restore" option.

Below is what i see on my end:

-> I select the latest package version.

-> Then right click and select "older versions"

-> All old version packages are listed inside the latest package version.

-> if i select the "old version packages" i see only "Restore" option.

Avatar

Community Advisor

Typically, in the package manager, when you install a new version of the content package name, you would be able to see all the packages listed under "other versions". Uninstall ('DELETE") does not exist, so you would need to manage and uninstall packages under http://localhost:4502/miscadmin#/etc/packages. Clicking on "Restore" means that you are re-installing the older package, which will overwrite your existing resources of whats currently set in the filters.

 

Also try restarting your AEM instance after deletion.

 

what AEM Version are you using, and have you installed the latest service pack? I had some problems like this in the past, and updating the service pack solved the problem.

Avatar

Level 3
Thanks for the explanation. I have tried to delete the packages from miscadmin and i was able to delete the packages.

Avatar

Correct answer by
Community Advisor

Hello,

I've actually written a script that does this, you can find it here: https://github.com/theopendle/aem-purge-packages

Packages are stored in the JCR like any other node. You can find them all under /etc/packages. For example, here are multiple versions of AEM Core Components on my instance:

Selection_121.png

 

For every package on your system, my script will keep only the most recent version and delete (no uninstall) all the others. 

If you run the script, it will first analyse your packages and tell you 

  • How many outdated packages are to be deleted
  • How much space it will save

You can then choose to continue or not:

$ python3 aem-purge-packages.py
Namespace(date=None, force=False, host=None, path=None, user=None, verbose=False)
Getting package list from AEM ...
Done
913 packages found
110 outdated packages found
Getting package list from AEM ...
Done
Purging outdated packages will remove 1.49 GB / 4.31 GB of package data
Do you wish to continue? (y/n):

 

In my case, I chose to continue, and you can see that it removed the older versions of each package:

Selection_117.png

Run the script with the -f flag to prevent it from asking for confirmation for every single deletion. Run it with the -h flag to see more options.

 

However please BEWARE!

  1. I recommend that you back up your system before making any kind of large automated purges as a general rule of thumb, including this script.
  2. There is a dependency system for packages. Future packages (including official Adobe ones) might have references to older packages that my script would purge (not the case on my instance, but if you have a old instance that was upgraded many times, it could happen). For example, here are the dependencies for the latest ACS Commons content package:
    Selection_118.png 
    If I delete a dependency, here is what happens:
    Selection_119.png
    This is a sort of "false positive" because the dependency package is gone, but the content of the package had already been installed, so everything works fine. 

If you want to improve my script to exclude packages from the purge if they are dependencies of other packages, you are more than welcome!

Avatar

Level 3

Hi - I am getting below syntax error while i running phyton script. I am running this on my local machine where AEM 6.5 installed trail version of "weretail".

Does this mean there's no outdated package on my instance? Kindly assist!!!

 

Phyton 3.8.2 is installed on my machine.

 

C:\Users\Surendar\Desktop>py aem-purge-packages.py
aem-purge-packages.py:49: SyntaxWarning: "is" with a literal. Did you mean "=="?
if len(outdated_packages) is 0:
aem-purge-packages.py:133: SyntaxWarning: "is" with a literal. Did you mean "=="?
if comparison is 0:
aem-purge-packages.py:210: SyntaxWarning: "is" with a literal. Did you mean "=="?
delete = confirmation is 'y'
aem-purge-packages.py:212: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if confirmation is not 'n':
aem-purge-packages.py:227: SyntaxWarning: "is" with a literal. Did you mean "=="?
confirmation = force or input("Do you wish to continue? (y/n)") is 'y'
aem-purge-packages.py:285: SyntaxWarning: "is" with a literal. Did you mean "=="?
if len(search.groups()) is 3:
Traceback (most recent call last):
File "aem-purge-packages.py", line 3, in <module>
import requests
ModuleNotFoundError: No module named 'requests'

C:\Users\Surendar\Desktop>

Avatar

Community Advisor
Hi, yes you'll have into install that module using pip (similar to npm for Node.js), here is the command: pip3 install requests