From 826e08d1161c8878aa1712fab04d174ce06970b1 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Thu, 29 Jun 2023 13:48:40 -0700 Subject: [PATCH] Retain a maximum 3 backups by default --- backup-cores.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backup-cores.sh b/backup-cores.sh index a4bb73e..1ba7a64 100755 --- a/backup-cores.sh +++ b/backup-cores.sh @@ -4,17 +4,18 @@ if [[ ! "$1" ]]; then echo """ Usage: $0 -Create backups for all cores in a solr instance. +Create backups for all cores in a solr instance. Currently hard-coded to keep 3 backups. """ exit 1 fi -SOLR_ROOT="${1?:Usage: $0 }" +NUMBER_TO_KEEP="3" +SOLR_ROOT="$1" command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but not installed. Aborting."; exit 1; } command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required but not installed. Aborting."; exit 1; } for core in $(curl -s $SOLR_ROOT/solr/admin/cores?indexInfo=false | jq -r '.status' | jq -r 'keys[]'); do echo "Backing up $core" - curl "${SOLR_ROOT}/solr/${core}/replication?command=backup" + curl "${SOLR_ROOT}/solr/${core}/replication?command=backup&numberToKeep=${NUMBER_TO_KEEP}" done