Skip to content

Instantly share code, notes, and snippets.

@Efrat19
Last active October 22, 2019 11:56
Show Gist options
  • Save Efrat19/3c29bec44b07292b91ea167df02ccfcc to your computer and use it in GitHub Desktop.
Save Efrat19/3c29bec44b07292b91ea167df02ccfcc to your computer and use it in GitHub Desktop.
clone all elastic indexes settings & mapping
#! /bin/bash
# in this script I assume you got elasticdump installed. https://github.com/taskrabbit/elasticsearch-dump
# if not, either run
# npm i -g elasticdump
# or use npx.
export SOURCE_HOST=http://localhost:9200
export DEST_HOST=http://localhost:9201
# clone settings
curl -s ${SOURCE_HOST}/_cat/indices \
| awk '{ print $3 }' \
| xargs -I index elasticdump \
--input ${SOURCE_HOST}/index --output ${DEST_HOST}/index --type settings
# clone mapping
curl -s ${SOURCE_HOST}/_cat/indices \
| awk '{ print $3 }' \
| xargs -I index elasticdump \
--input ${SOURCE_HOST}/index --output ${DEST_HOST}/index --type mapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment