# How can I export data from index A and import it to index B?

**URL:** https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128
**Category:** Elasticsearch
**Created:** [December 17, 2019, 9:43am UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128 "2019-12-17T09:43:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![soniadailyview](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@soniadailyview](https://discuss.elastic.co/u/soniadailyview)
#### Post date: [December 17, 2019, 9:43am UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128/1 "2019-12-17T09:43:22Z")

</div>

Hi,

I have the needs to backup data and dump data from production environment to stage.

The size of one index is about 20G.

I've tried using elasticsearch-dump but it is too slow.

And I also try to use snapshot but have difficulties in renaming the index.

I know snapshot may restore data with the same index to other cluster easily but not sure if this could also restore data to new index on the same cluster.

Does anyone have a better solution or how to do it?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [December 17, 2019, 12:20pm UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128/2 "2019-12-17T12:20:05Z")

</div>

you can try [reindex from remote](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/reindex-upgrade-remote.html), or if the clusters cannot communicate with each other using snapshot and restore in combination with `rename_pattern` and `rename_replacement` will work as well.

--Alex

---

<div class="post-metadata">

### Author: ![soniadailyview](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@soniadailyview](https://discuss.elastic.co/u/soniadailyview)
#### Post date: [December 18, 2019, 2:11am UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128/3 "2019-12-18T02:11:23Z")

</div>

Hi Alex,

To my understanding, reindex is more like migration, moving data from index A to index B. Only one piece of data exists. But what I want to do is copying the data. I have two indices, A and B, and they have the same data. Am I getting you correctly?

Besides, I have few questions about using snapshot.

Let's say I have a repo called `posts` and a snapshot called `post_20191218`. The original index is `posts` and I want to restore the data to index `posts_2019`. So the `rename_pattern` is 'posts' and `rename_replacement` is '$1\_2019'?

```
I got the error message by using api lol. The answer is `post` to `post_2019`. That's it.

```

The second question is if I want to restore the data from production to stage using snapshot, I have to transmit the snapshot on production to stage, right? Or is there any remote api that I could access the snapshot on remote machine and restore on local?

Thank you so much. As a newcomer in elasticsearch, your reply is so helpful to me!

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [December 18, 2019, 8:47am UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128/4 "2019-12-18T08:47:35Z")

</div>

reindex will also leave you with two indices, but there is one fundamental difference. reindex will index each document individually again, doing all the analysis before storing the data. This is usually used when you change the mapping.

Restoring an index basically just copies the original data from the repository and then loads the index from that data - involving much less CPU as there is no reindex work.

Usually you snapshot your data to a remote repository, which you then also make accessible for the other cluster. Another possibility is to copy your data somewhere where it is available via HTTP and use [read only repositories](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/modules-snapshots.html#_read_only_url_repository), that cannot be used for snapshotting, but for restoring only.

---

<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: [January 15, 2020, 8:47am UTC](https://discuss.elastic.co/t/how-can-i-export-data-from-index-a-and-import-it-to-index-b/212128/5 "2020-01-15T08:47:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
