Created
September 21, 2018 13:10
-
-
Save puttpotsawee/6eaeb6176e04752e780b0d2999c5a6df to your computer and use it in GitHub Desktop.
Create Remote Reindex from existing indices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OLD_CLUSTER=localhost:9201 | |
NEW_CLUSTER=localhost:9202 | |
OLD_CLUSTER_SERVICE=logging-elastic-service-old:9200 | |
indices=$(curl $OLD_CLUSTER/_cat/indices | awk '{ print $3 }') | |
printf "\n\n+++++reindexing those index+++++++\n" | |
for index in $indices; do | |
# get your indices prefix, write this regex to grasp your indices but skip .kibana index | |
if ! [[ $index =~ ^log.*$ ]]; then | |
continue | |
fi | |
printf "\n====Reindexing ${index}====\n" | |
# run reindexing API | |
curl -XPOST ${NEW_CLUSTER}/_reindex -H 'content-type: application/json' -d "{\"source\":{\"remote\":{\"host\":\"http://${OLD_CLUSTER_SERVICE}\", \"socket_timeout\": \"10m\", \"connect_timeout\": \"1m\"},\"index\":\"${index}\"},\"dest\":{\"index\":\"${index}\"}}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment