Last active
September 27, 2016 14:31
-
-
Save jayankandathil/5782117 to your computer and use it in GitHub Desktop.
Bash shell script to run Adobe CQ (Experience Manager) maintenance operations on Red Hat Enterprise Linux. Tested on RHEL 6.3 and 6.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bash script to run CQ daily maintenance operations, excluding TarPM Optimization and Tar Index Merge | |
# 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 run | |
# 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 | |
USER=admin | |
# CQ Admin user password | |
PASSWORD=admin | |
# CQ Home | |
CQ_HOME=/mnt/cq/crx-quickstart | |
# CQ Maintenance in progress file | |
MAINTENANCE_FILE=$CQ_HOME/logs/maintenance_in_progress.txt | |
# CQ Maintenance log file | |
LOG_FILE=$CQ_HOME/logs/cq_maintenance.log | |
# Source Folder where CQ is backed up (no trailing forward slash) | |
CQ_BACKUP_FOLDER=/mnt/cq/backup | |
# Don't change the file name backupInProgress.txt CQ creates it automatically on Backup start, and deletes it when Backup finishes) | |
BACKUP_FILE=$CQ_BACKUP_FOLDER/backupInProgress.txt | |
# ------------------------------------------------ | |
# Do not configure below this point | |
# ------------------------------------------------ | |
# Log timestamp | |
date | tee -a $LOG_FILE | |
# Back off if the previous maintenance operation is still in progress | |
if [ -f $MAINTENANCE_FILE ]; | |
then | |
echo $'\n'"Previous maintenance operation still in progress..., backing off till next time."$'\n' | tee -a $LOG_FILE | |
else | |
# Back off if CQ Backup is in progress | |
if [ -f $BACKUP_FILE ]; | |
then | |
echo $'\n'"Incremental CQ Backup in progress..., backing off till next time."$'\n' | tee -a $LOG_FILE | |
else | |
#Create an empty text file indicating maintenance in progress | |
touch $MAINTENANCE_FILE | tee -a $LOG_FILE | |
# Consistency Check | |
echo "Starting JCR consistency check..."$'\n' | |
START=$(date +%s) | |
time curl -u $USER:$PASSWORD -X POST --data "rootNode=%2F&fixInconsistencies=true" http://$HOST:$PORT/system/console/jmx/com.adobe.granite%3Atype%3DRepository/op/consistencyCheck/java.lang.String%2Cjava.lang.Boolean | tee -a $LOG_FILE | |
END=$(date +%s) | |
DIFF=$(( $END - $START )) | |
echo "Finished."$'\n' | |
echo "Took $DIFF seconds"$'\n' | |
# Traversal Check | |
echo "Starting JCR traversal check..."$'\n' | |
START=$(date +%s) | |
time curl -u $USER:$PASSWORD -X POST --data "fixInconsistencies=true&logEach=false&rootNode=%2F" http://$HOST:$PORT/system/console/jmx/com.adobe.granite%3Atype%3DRepository/op/traversalCheck/java.lang.String%2Cjava.lang.Boolean%2Cjava.lang.Boolean | tee -a $LOG_FILE | |
END=$(date +%s) | |
DIFF=$(( $END - $START )) | |
echo "Finished."$'\n' | |
echo "Took $DIFF seconds"$'\n' | |
# Data Store Garbage Collection (only pre-v5.6.0) | |
# in v5.6.0 and newer, use the OSGi config "Repository Garbage Collection Scheduler" | |
echo $'\n'"Starting Data Store garbage collection..."$'\n' | |
START=$(date +%s) | |
time curl -u $USER:$PASSWORD -X POST --data "delete=true&delay=1" http://$HOST:$PORT/system/console/jmx/com.adobe.granite%3Atype%3DRepository/op/runDataStoreGarbageCollection/java.lang.Boolean | tee -a $LOG_FILE | |
END=$(date +%s) | |
DIFF=$(( $END - $START )) | |
echo "Finished."$'\n' | |
echo "Took $DIFF seconds"$'\n' | |
# Remove file which indicates that maintenance is in progress | |
rm $MAINTENANCE_FILE | tee -a $LOG_FILE | |
fi | |
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
What is the use of running consistency check and traversal check before the actual operation?And maintaining logs for these 2 process which seem irrelevant when it comes to running the datastor garbage collector.