Skip to content

Commit

Permalink
-> backup script updates
Browse files Browse the repository at this point in the history
  • Loading branch information
s-paquette committed Aug 22, 2023
1 parent 15c19d9 commit cf9fdcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions shell/backup-solr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MAX_WAIT=3
SOLR_DATA="/opt/bitnami/solr/server/solr"
RUN=`date +%s`
BACKUPS_DIR="${SOLR_DATA}/backups_${RUN}"
PARSE_RESPONSE="import sys, json; print(json.load(sys.stdin)['details']['backup'].get('snapshotCompletedAt',None) or 'INCOMPLETE')"
PARSE_RESPONSE="import sys, json; print(json.load(sys.stdin)['details'].get('backup',{}).get('snapshotCompletedAt',None) or 'INCOMPLETE')"

while getopts ":c:l:f:d:h" flag
do
Expand Down Expand Up @@ -85,8 +85,9 @@ for core in "${cores[@]}"; do
while [[ "$status" == "INCOMPLETE" && "$retries" -lt "$MAX_WAIT" ]]; do
echo "Backup for core ${core} isn't completed, waiting..."
sleep 2
((retries++))
((retries=retries+1))
status=`curl -s -u ${SOLR_USER}:${SOLR_PWD} -X GET "https://localhost:8983/solr/${core}/replication?command=details" --cacert solr-ssl.pem | python3 -c "${PARSE_RESPONSE}"`
echo "Status is now ${status}"
done
if [ "$status" != "INCOMPLETE" ]; then
echo "Core ${core} backup completed at ${status}."
Expand Down
4 changes: 2 additions & 2 deletions shell/restore-solr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ else
fi
fi

if [[ -z $SOLR_PWD ]]; then
if [ -z $SOLR_PWD ]; then
echo "[ERROR] SOLR_PWD not set - exiting!"
exit 1
fi
Expand Down Expand Up @@ -68,7 +68,7 @@ for dirname in ${BACKUP_DIR}/*/; do
fi
if [ "$MAKE_CORE" = true ]; then
echo "[STATUS] Core creation enabled - attempting creation of core \"${CORE}\"..."
sudo -u solr /opt/bitnami/solr/bin/solr create -c $CORE -s 2 -rf 2
sudo -u solr solr create -c $CORE
else
echo "[STATUS] Core creation disabled - this assumes core \"${CORE}\" exists already!"
echo " You'll see an error if it doesn't."
Expand Down

0 comments on commit cf9fdcd

Please sign in to comment.