elasticsearch,

How to export and import Elasticsearch Index with Docker

Sep 17, 2021 · 2 mins read · Post a comment
How to export and import Elasticsearch Index with Docker

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 - The input parameter is used to tell you from which ES endpoint you want to take the specified index.
  • --output - The output parameter is used to tell you on which ES endpoint you want to copy the specified index.
  • --type - The type parameter is used to decide what do you want to export. If you don’t specify it will export data by default. Here is a list of the types that can be exported:
    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.