Forked from aterreno/migrate-elastic-search-indexes.sh
Created
July 30, 2017 09:08
-
-
Save ANemcov/817385cc1b5f24086235c852dd951f10 to your computer and use it in GitHub Desktop.
Script to migrate elastic search index mappings between one host and another one
This file contains hidden or 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 | |
SOURCE_URI='http://10.251.76.43:9200' | |
DEST_URI='http://localhost:9200' | |
declare -a indexes=(gallery linklist module pageversion poll standardmodule styles video) | |
echo "Getting mappings from: $SOURCE_URI" | |
for index in ${indexes[@]} | |
do | |
echo "Exporting: $index" | |
curl -XGET "$SOURCE_URI/$index/$index/_mapping" > $index".json" | |
done | |
echo "Recreating mappings in: $DEST_URI" | |
for index in ${indexes[@]} | |
do | |
echo "Creating: $index" | |
curl -XPUT "$DEST_URI/$index/" | |
curl -XPUT "$DEST_URI/$index/$index/_mapping" -d @"$index.json" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment