Skip to content

Commit 826e08d

Browse files
author
Daniel Schmidt
committed
Retain a maximum 3 backups by default
1 parent a0b2cd1 commit 826e08d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

backup-cores.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ if [[ ! "$1" ]]; then
44
echo """
55
Usage: $0 <solr root>
66
7-
Create backups for all cores in a solr instance.
7+
Create backups for all cores in a solr instance. Currently hard-coded to keep 3 backups.
88
"""
99
exit 1
1010
fi
1111

12-
SOLR_ROOT="${1?:Usage: $0 <solr root>}"
12+
NUMBER_TO_KEEP="3"
13+
SOLR_ROOT="$1"
1314

1415
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but not installed. Aborting."; exit 1; }
1516
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required but not installed. Aborting."; exit 1; }
1617

1718
for core in $(curl -s $SOLR_ROOT/solr/admin/cores?indexInfo=false | jq -r '.status' | jq -r 'keys[]'); do
1819
echo "Backing up $core"
19-
curl "${SOLR_ROOT}/solr/${core}/replication?command=backup"
20+
curl "${SOLR_ROOT}/solr/${core}/replication?command=backup&numberToKeep=${NUMBER_TO_KEEP}"
2021
done

0 commit comments

Comments
 (0)