Skip to content

Commit

Permalink
Merge branch 'rpb-137-deleteIndices' of https://github.com/hbz/rpb in…
Browse files Browse the repository at this point in the history
…to main

Resolves https://jira.hbz-nrw.de/browse/RPB-137

See also #80
  • Loading branch information
fsteeg committed Apr 29, 2024
2 parents 88c6b24 + 152ab10 commit 11ce556
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions deleteOldIndices.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euxo pipefail

# Delete matching non-aliased indices, but keep the newest

HOST="localhost"
INDICES=("gnd-rppd-*" "resources-rpb-*")

for INDEX in "${INDICES[@]}"
do
curl -s -S -X GET "$HOST:9200/_cluster/state?filter_path=metadata.indices.$INDEX.aliases&pretty" |
jq -r '.metadata.indices | to_entries[] | select(.value.aliases | length == 0) | .key' | # no alias
sort | head -n -1 | # don't include the newest index
awk -v HOST="$HOST" '{print HOST":9200/"$1"?pretty"}' |
xargs -L 1 curl -s -S -v -X DELETE
done

0 comments on commit 11ce556

Please sign in to comment.