adamcin / net.adamcin.recap

Recap - rsync for Adobe Granite
http://adamcin.net/net.adamcin.recap
16 stars 15 forks source link

Call Recap from command line #1

Open sgu222e opened 10 years ago

sgu222e commented 10 years ago

Hi Mark,

This might turn into a 2-part question. Could Recap be called from command line with Curl? I'm going to experiment with this myself. Do you think it would be possible to setup an automated task, either in AEM itself or using command line, to copy content from 1 location to another on a scheduled basis? This would be useful for keeping backups or keeping my QA environment up to date with production content.

Thank in advance,

Leigh C

adamcin commented 10 years ago

Hi Leigh,

The short answer is "yes, that should work". I designed this application around a fully-functional internal API, plus supporting servlets which accept simple POST commands with consistent parameters to trigger the remote copy action. Also, if you switch the request extension to .txt, the progress log should be written to the response without HTML markup, so you can use it with curl by redirecting the response to a flat file.

You can look at the code for the AddressBook CopyFrom servlet here:

https://github.com/adamcin/net.adamcin.recap/blob/master/addressbook/src/main/java/net/adamcin/recap/addressbook/impl/servlet/CopyFromServlet.java

You can call this servlet by POSTing a list of paths using the ":paths" parameter (either within a single value separated by \n or with multiple :paths values) to an address node within your user's address book, using the "copy" selector, as in:

curl -u admin:admin -Fcharset=utf-8 -F:paths=/content/path1 -F:paths=/content/path2 -o ./recapProgress.txt "http://localhost:4502/home/users/a/admin/recapAddresses/address_10293012908.copy.txt"

Additionally, all the RecapConstants.RP_* parameters are supported (for simple and advanced copy options). Take a look at the JSP for the UI form that triggers a copy to see how they are used:

https://github.com/adamcin/net.adamcin.recap/blob/master/graniteui/src/main/content/jcr_root/components/addressbook/address/html.GET.jsp

I hope that is enough to get you started.

Mark

adamcin commented 10 years ago

And while I have not provided a scheduler UI to support internal scheduling of transfers out-of-the-box, all of the Recap services are exposed to OSGi with public APIs, so it should be fairly easy for you to create a Runnable service in your own custom code which sets up and executes a RecapSession on a regular interval.

Mark

chadlnc commented 9 years ago

I know this issue is pretty old now, but for anyone else that happens across this, it works well for us. I ran it from the web gui to figure out exactly which posts i needed. Here is an example of one that we run to bring content from production to dev:

curl -u admin:admin -Fcharset=utf-8 -F:only_newer=false -F:update=true -F:paths=/content "http://author_address:4502/home/users/a/admin/recapAddresses/prod_auth.copy.txt"

chanti28 commented 8 years ago

Hi Team, I'm new to recap , I have a doubt once we installed the recap in servers by default it will trigger on every 0:00 PST. how it will happens is their any default configuration or we have to run manually????

Nightfirecat commented 7 years ago

Old issue, but for any who want to create a Recap address from the command line, you can use the following command.

curl -u admin:prod_auth_password -F_charset_=utf-8 -Fjcr:title=prod_auth -Fsling:resourceType=recap/components/addressbook/address -Fhostname=prodauth.example.com -Fport=4502 -Fusername=admin -Fpassword=password -FisHttps=false "http://author_address:4502/home/users/a/admin/recapAddresses/*.txt"