Skip to content

Commit

Permalink
Retain a maximum 3 backups by default
Browse files Browse the repository at this point in the history
  • Loading branch information
danschmidt5189 committed Jun 29, 2023
1 parent a0b2cd1 commit 826e08d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backup-cores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ if [[ ! "$1" ]]; then
echo """
Usage: $0 <solr root>
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 <solr root>}"
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

0 comments on commit 826e08d

Please sign in to comment.