Skip to content

Instantly share code, notes, and snippets.

@jayankandathil
Last active December 13, 2016 15:56
Show Gist options
  • Save jayankandathil/6030785 to your computer and use it in GitHub Desktop.
Save jayankandathil/6030785 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Bash script to invoke CQ Backup using CURL
# Author : Jayan Kandathil
# Version : 0.4
# Last updated : May 24, 2013
# Instructions : Copy to CQ's /bin folder, make necessary changes, enable the execute bit and test
# Echo on (for debugging purposes)
# set -x verbose
# Host that CQ runs on
HOST=localhost
# TCP port CQ listens on
PORT=4502
# CQ Admin user ID
CQ_USER=admin
# CQ Admin user password
CQ_USER_PASSWORD=admin
# Source Folder where CQ is backed up (no trailing forward slash)
CQ_BACKUP_FOLDER=/mnt/crx/author/backup
# CQ Backup in progress file (CQ creates it automatically on Backup start, and deletes it when Backup finishes)
BACKUP_FILE=$CQ_BACKUP_FOLDER/backupInProgress.txt
# CQ /crx-quickstart Folder Path (%2F is the forward slash character)
CQ_ROOT=%2Fmnt%2Fcrx%2Fauthor%2Fcrx-quickstart
# CQ Backup Target Folder Path
CQ_BACKUP_ROOT=%2Fmnt%2Fcrx%2Fauthor%2Fbackup
# CQ Home
CQ_HOME=/mnt/crx/author/crx-quickstart
# CQ Backup log file
LOG_FILE=$CQ_HOME/logs/cq_backup.log
# ------------------------------------------------
# Do not configure below this point
# ------------------------------------------------
# Log timestamp
date | tee -a $LOG_FILE
# Back off if the previous Backup is still not finished
if [ -f $BACKUP_FILE ];
then
echo "Prevous Backup still in progress..., backing off till next time." | tee -a $LOG_FILE
else
echo "Starting incremental CQ Backup..." | tee -a $LOG_FILE
# Initiate CQ Backup using curl
curl -u $CQ_USER:$CQ_USER_PASSWORD -X POST --data "_charset_=utf-8&delay=1&force=true&installDir=$CQ_ROOT&target=$CQ_BACKUP_ROOT" http://$HOST:$PORT/libs/granite/backup/content/admin/backups/ | tee -a $LOG_FILE
echo "CQ incremental Backup started asynchronously - please check CQ error.log for details" | tee -a $LOG_FILE
fi
# Log timestamp
date | tee -a $LOG_FILE
echo $'\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment