elasticsearch, docker,

How to export and import Elasticsearch Index with Docker

Sep 17, 2021 · 1 min read · Post a comment

Synchronizing the ES index data between your prod, dev and local ES cluster environment is now achievable with Docker. Moving the index data, mapping or analyzer can be done through the elasticsearch-dump Docker image. In this tutorial, I’ll show you a few examples of how to move your indexes between different environments.

Prerequisites

  • Prod ES cluster
  • Local/Dev/Stage ES cluster

Copy index from one ES cluster to another

Step 1. If there is a need to copy index from production ES to dev ES with the mappings, to sync the data between them, you can do it by running the following command:

docker run --rm -ti elasticdump/elasticsearch-dump \
  --input=http://prod.es.io:9200/index_name \
  --output=http://dev.es.io:9200/index_name \
  --type=mapping

Step 2. Copying the same index but instead of mapping if you want to copy the data or analyzer, run:

docker run --rm -ti elasticdump/elasticsearch-dump \
  --input=http://prod.es.io:9200/index_name \
  --output=http://dev.es.io:9200/index_name \
  --type=data

docker run --rm -ti elasticdump/elasticsearch-dump \
  --input=http://prod.es.io:9200/index_name \
  --output=http://dev.es.io:9200/index_name \
  --type=analyzer
  • --input: Used to tell you from which ES endpoint you want to take the specified index.
  • --output: Used to tell you on which ES endpoint you want to copy the specified index.
  • --type: Used to decide what do you want to export. If it’s not added, it will export data by default. Here is a list of exportable types:
    settings, analyzer, data, mapping, policy, alias, template, component_template, index_template
    

Conclusion

Instead of installing the elasticdump command you can use the elasticsearch-dump Docker image which can save you time and resources while syncing your ES environments. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.