Need to automate content package creation and scheduling it weekly | Community
Skip to main content
Level 4
September 21, 2016
Solved

Need to automate content package creation and scheduling it weekly

  • September 21, 2016
  • 13 replies
  • 7347 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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.

13 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
September 21, 2016

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.

joerghoh
Adobe Employee
Adobe Employee
September 21, 2016

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/package-summary.html

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

AnkurAhlawat-1
Level 6
September 22, 2016

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

kautuk_sahni
Community Manager
Community Manager
September 22, 2016

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
Level 4
September 22, 2016

Hi,

Can we schedule to run curl commands weekly or daily?

 

Regards,

Shallu Rohilla

kautuk_sahni
Community Manager
Community Manager
September 29, 2016

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
Feike_Visser1
Adobe Employee
Adobe Employee
September 29, 2016

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

kautuk_sahni
Community Manager
Community Manager
September 30, 2016

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
Level 5
September 30, 2016

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=build

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

Level 4
October 1, 2016

I am using CQ5.6.