Question
Starting with CQ5.5, an Online backup cannot be triggered anymore via the CRX Web console. This functionality was moved to the JMX plug-in available now in the Adobe CQ5 Web Console (formerly known as Felix Console).
How is it possible to trigger certain Online Backup operations in an automated manner using shell scripts and cronjobs for example?
Answer
It is possible to execute Online Backup operations that the corresponding JMX MBean exposes using HTTP requests in a RESTful manner.
This article describes how to perform these HTTP requests based on cURL for sending requests.
The JMX MBean in question is of domain com.adobe.granite, type Repository.
Requests
Start a backup with an explicit delay (in ms):
# start backup with 1ms delay curl -u admin:<pwd> -F"target=mybackup.zip" -F"force=true" -F"delay=1" http://<host>:<port>/libs/granite/backup/content/admin/backups.html
To download a backup, use the following cURL command:
# download backup-zip file with GET curl -u admin:<pwd> "http://<host>:<port>/libs/granite/backup/content/admin/backup.download.html?<absolute_path_to_backup_zip>
Deleting a backup-zip file works similar with a POST request:
# delete backup-zip file with POST curl -u admin:<pwd> -F"path=<absolute_path_to_backup_zip>" http://<host>:<port>/libs/granite/backup/content/admin/backup.delete.html
Canceling a backup is also possible with a POST to the following:
# cancel current backup with POST curl -u admin:<pwd> -X POST http://<host>:<port>/libs/granite/backup/content/admin/backups.cancel.html
The cURL command to create a backup-zip file returns immediately since the backup creation has been deferred to an asynchronous thread.
To determine whether a backup has finished and its corresponding backup-zipfile is completed from a script point of view, monitor the target directory. A temp directory is created while the backup is in progress. The name of the temp directory is based on the provided zipfile name for the backup. For example:
- name of backup zip-file: backup-author-120713.zip
- name of temp directory: backup-author-120713.<xyz>.temp
The <xyz> part is dynamic. Once the backup is finished, the contents of this temp directory is zipped and removed afterwards.