# How can I use elasticdump to reindex an entire cluster?

**URL:** <https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162>\
**Category:** Elasticsearch\
**Created:** [January 26, 2016, 8:25pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162 "2016-01-26T20:25:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhaedrusTheGreek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phaedrusthegreek/32/4884_2.png) [@PhaedrusTheGreek](https://discuss.elastic.co/u/PhaedrusTheGreek)\
**Post date:** [January 26, 2016, 8:25pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162/1 "2016-01-26T20:25:08Z")

</div>

I love elasticdump! How can I use it to reindex my entire cluster?

Also, if one giant file is too much, is there some script that I can run to split it out into multiple files?

---

<div class="post-metadata">

**Author:** ![PhaedrusTheGreek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phaedrusthegreek/32/4884_2.png) [@PhaedrusTheGreek](https://discuss.elastic.co/u/PhaedrusTheGreek)\
**Post date:** [January 26, 2016, 8:26pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162/2 "2016-01-26T20:26:18Z")

</div>

This will dump the whole cluster and reindex it.

Also, this does not retain mappings, so you'll want to make sure that your dynamic mappings (with the new index settings) are in place prior to the reindex.

Plus, realize that dumping the entire cluster into a single file is quick and dirty, and god knows what could go wrong.

```auto
$ yum install npm
$ npm install elasticdump
$ node_modules/elasticdump/bin/elasticdump \
    --input=http://<es_ip>:9200/ \
    --output=./whole_cluster.json --all=true
$ node_modules/elasticdump/bin/elasticdump \
    --output=http://<es_ip>:9200/ \
    --input=./whole_cluster.json --bulk=true

```

A safer way might be to dump into multiple files. You could use a script like this:

```auto
#!/bin/bash
# Usage:
# ./reindex.sh dump
# ./reindex.sh restore
ES=http://localhost:9200/
ED=./node_modules/elasticdump/bin/elasticdump

dump() {
for index in `/usr/bin/curl -s -XGET $ES/_cat/indices?h=i `
do
        echo $index
        $ED --input=$ES/$index --output=$index.json
done
}

restore() {
FILES=*.json
for f in $FILES
do
        echo "Processing $f ..."
        $ED --bulk=true --input=$f --output=$ES
done
}

$1; exit $?

```

Be warned that neither of the above methods is necessarily an efficient or safe way to reindex a cluster. Other tools such as [stream2es](https://github.com/elasticsearch/stream2es) can be parallelized and are better suited to heavy workloads.

Also see the [elasticdump docs](https://www.npmjs.com/package/elasticdump).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 26, 2016, 10:07pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162/3 "2016-01-26T22:07:12Z")

</div>

I use Logstash for this - [https://gist.github.com/markwalkom/8a7201e3f6ea4354ae06](https://gist.github.com/markwalkom/8a7201e3f6ea4354ae06) 🙂

---

<div class="post-metadata">

**Author:** ![varunmehta](https://avatars.discourse-cdn.com/v4/letter/v/b19c9b/32.png) [@varunmehta](https://discuss.elastic.co/u/varunmehta)\
**Post date:** [January 27, 2016, 4:45pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162/4 "2016-01-27T16:45:50Z")

</div>

Finally came up with this script using elasticdump.

> <https://gist.github.com/varunmehta/d0553071dad4171e4dd7>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:21pm UTC](https://discuss.elastic.co/t/how-can-i-use-elasticdump-to-reindex-an-entire-cluster/40162/5 "2017-07-05T23:21:02Z")

</div>


