Skip to content

Commit 6ae5985

Browse files
committed
Add script to delete non-aliased indices, keeping newest (RPB-137)
1 parent 84b3cf2 commit 6ae5985

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

deleteOldIndices.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
# Delete matching non-aliased indices, but keep the newest
5+
6+
indices=("gnd-rppd*" "resources-rpb*")
7+
for index in "${indices[@]}"
8+
do
9+
curl -s -S -X GET "localhost:9200/_cluster/state?filter_path=metadata.indices.$index.aliases&pretty" |
10+
jq -r '.metadata.indices | to_entries[] | select(.value.aliases | length == 0) | .key' | # no alias
11+
sort | head -n -1 | # don't include the newest index
12+
awk '{print "localhost:9200/"$1"?pretty"}' |
13+
xargs -L 1 curl -s -S -v -X DELETE
14+
done

0 commit comments

Comments
 (0)