Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Need to automate content package creation and scheduling it weekly

Avatar

Level 4

Hi,

Is there a way we can automate content package creation on any environment and also schedule this creation?

Any pointers would be helpful.

 

We also open to the idea of creating repository backup but that should be automated and scheduled.

 

Regards,

Shallu Rohilla

1 Accepted Solution

Avatar

Correct answer by
Level 10

Look at using Package Manager API and write a custom service. Fire off the service each week.  Look at this Javadoc. https://docs.adobe.com/docs/en/cq/5-5/javadoc/com/day/jcr/vault/packaging/PackageManager.html. Hope this helps.

View solution in original post

13 Replies

Avatar

Correct answer by
Level 10

Look at using Package Manager API and write a custom service. Fire off the service each week.  Look at this Javadoc. https://docs.adobe.com/docs/en/cq/5-5/javadoc/com/day/jcr/vault/packaging/PackageManager.html. Hope this helps.

Avatar

Employee Advisor

There is no ootb solution for this, but can write code to do that. You should start with the Jackrabbit Vault API [1], which allows you programmatically modify packages and operate on them. The entry point of your code is the packaging service [2], where you can get a JcrPackageManager.

Jörg

 

[1] https://jackrabbit.apache.org/filevault/apidocs/index.html?org/apache/jackrabbit/vault/packaging/pac...

[2] https://jackrabbit.apache.org/filevault/apidocs/org/apache/jackrabbit/vault/packaging/Packaging.html

Avatar

Level 7

If i had to automate content package creation then i personally prefer using Curl commands. These are fast and easy to use. smiley

See this How to use curl commands in aem

Avatar

Administrator

Hi

The package manager does expose an HTTP service interface, which allows managing packages using through Command Line Interface. You can use curl or any other command line clients to achieve this.

The Package Manager Documentation provides the complete details on the various operations that are supported, the request and the response format, and some sample commands.

For e.g, the following is the curl command to create a new package.

curl -u <uid>:<pwd> -X POST
http://localhost:<port>/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create 
-d packageName=<name> -d groupName=<name> 

Fore Creating Package with filters :- http://aemfaq.blogspot.in/2013/09/creating-package-with-filtersexclusion.html

 

Apart from the HTTP service, you may also use Java API to manage packages. Start with this OSGi service: com.day.jcr.vault.packaging.Packaging

 

~kautuk



Kautuk Sahni

Avatar

Level 4

Hi,

Can we schedule to run curl commands weekly or daily?

 

Regards,

Shallu Rohilla

Avatar

Administrator

Shallu Rohilla wrote...

Hi,

Can we schedule to run curl commands weekly or daily?

 

Regards,

Shallu Rohilla

 

Hi,

Answer is YES. But not the perfect way to achieve it.

Link:- https://hashimkhan.in/2015/05/28/automate-curl-batch/

//    Automate it Completely

         Yes, I am too lazy to even manually click the batch file . I want it to be self executed after a particular time interval. This will be a powerful way to do a repeated task in AEM- eg a daily backup package, a         daily backup, a daily update of some content from a particular folder , etc. To do this you need to follow a few steps and you will not have to even execute it yourself.

        After creating your batch file , make sure that it is working fine as expected.
        Go to Windows> Start> Search for Task Scheduler (Windows 7)
        Create a Basic Task and fill the necessary details.
        Setup the time period in which you need to execute the batch file.
        At the Action Tab, Select a Program/Script and choose the path for your Batch file.
        Click Finish and you are done .

~kautuk



Kautuk Sahni

Avatar

Employee

You can also look at crx2oak to push down content from your higher environments, also these command are 'just' os commands.

Avatar

Administrator

Feike Visser wrote...

You can also look at crx2oak to push down content from your higher environments, also these command are 'just' os commands.

 

Thanks a lot Feike. This adds to my kitty.

Adding Documentation link here :- https://docs.adobe.com/docs/en/aem/6-2/deploy/upgrade/using-crx2oak.html



Kautuk Sahni

Avatar

Level 6

Hi Rohilla,

I have tried package back up but i didn't work in our scenario because of  too large data it won't work effectively the system is going down. Our content is like (2500 articles in each local * 30 locales). 

I am attaching the script you can run as it as a daily or weekly based on your environment like if it is a Linux need to use the CORN JOb or if it is windows can use the windows scheduler.

#!/bin/bash

echo "Starting" '\n'

curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/contentpackage?cmd=create \
-d packageName=contentpackage \
-d groupName=my_packages

echo '\n'

echo "Package Created" '\n'

# add filters
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/update.jsp \
-F path=/etc/packages/my_packages/contentpackage.zip -F packageName=contentpackage \
-F groupName=my_packages \
-F filter="[{\"root\" :\"/content/eacom0\", \"rules\": [{\"modifier\" : \"include\", \"pattern\" : \"/.*\"}]}]" \
-F '_charset_=UTF-8'

echo '\n'

echo "Filters Added" '\n'

# build package
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/contentpackage.zip?cmd=buil...

echo '\n'

echo "Package Built" '\n'

#download package

echo "Package downloading" '\n'

#curl -u admin:admin http://localhost:4502/etc/packages/export/contentpackage.zip >/home/ec2-user/backup/contentpackage$(date +%H%M%S.%N).zip

curl -u admin:admin http://localhost:4502/etc/packages/my_packages/contentpackage.zip>/home/ec2-user/backup/contentpackage$(date +%H%M%S.%N).zip

echo "end"

---------------------------------------------------------

  As a 2nd option I am using the vlt rcp command. This backup we can copy from one repository to other backup repository.  We can automate this one as well.

One quick question which version of CQ are u using? if it is CQ6+ version install the mongoDB . 

 

Thanks

Avatar

Employee

kautuksahni wrote...

Feike Visser wrote...

You can also look at crx2oak to push down content from your higher environments, also these command are 'just' os commands.

Thanks a lot Feike. This adds to my kitty.

Adding Documentation link here :- https://docs.adobe.com/docs/en/aem/6-2/deploy/upgrade/using-crx2oak.html

There are a couple of points to bear in mind when using crx2oak for this use case. First, both instances have to be shutdown in order to run the content migration and it is meant to be used when you have both AEM instances on the same box. Secondly, If you try and run it across a network, it could be very slow.

As this is 5.6, you can't use it to transfer from crx to crx, only cry to oak or oak to oak.

Regards,

Opkar

Avatar

Administrator

Opkar Gill wrote...

kautuksahni wrote...

Feike Visser wrote...

You can also look at crx2oak to push down content from your higher environments, also these command are 'just' os commands.

Thanks a lot Feike. This adds to my kitty.

Adding Documentation link here :- https://docs.adobe.com/docs/en/aem/6-2/deploy/upgrade/using-crx2oak.html

There are a couple of points to bear in mind when using crx2oak for this use case. First, both instances have to be shutdown in order to run the content migration and it is meant to be used when you have both AEM instances on the same box. Secondly, If you try and run it across a network, it could be very slow.

As this is 5.6, you can't use it to transfer from crx to crx, only cry to oak or oak to oak.

Regards,

Opkar

 

Thanks a lot Opkar.

Everyday i am learning awesome things from Experts.

Thanks a lot. 



Kautuk Sahni