Skip to content

Commit

Permalink
Add script to delete non-aliased indices, keeping newest (RPB-137)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Apr 25, 2024
1 parent 84b3cf2 commit 0c974ce
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions deleteOldIndices.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euxo pipefail

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

indices=("gnd-rppd*" "resources-rpb*")
for index in "${indices[@]}"
do
curl -s -S -X GET "weywot2: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 '{print "weywot2:9200/"$1"?pretty"}' |
xargs -L 1 curl -s -S -v -X DELETE
done

0 comments on commit 0c974ce

Please sign in to comment.