# Export ES indices based on time

**URL:** https://discuss.elastic.co/t/export-es-indices-based-on-time/29269
**Category:** Elasticsearch
**Created:** [September 14, 2015, 4:56pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269 "2015-09-14T16:56:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![michaellizhou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellizhou/32/4143_2.png) [@michaellizhou](https://discuss.elastic.co/u/michaellizhou)
#### Post date: [September 14, 2015, 4:56pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/1 "2015-09-14T16:56:39Z")

</div>

Is there a way to export ES indices from a time range? i.e. 1:00 PM - 2:00PM? I want to be able to export this range and send it another ES instance.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [September 14, 2015, 5:00pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/2 "2015-09-14T17:00:41Z")

</div>

There's no built-in mechanism for this. Unless there's an existing program that can do this ([Elasticsearch Knapsack](https://github.com/jprante/elasticsearch-knapsack) comes to mind) you'll have to write something yourself. It should be quite easy with e.g. [elasticsearch-py](https://elasticsearch-py.readthedocs.org/en/master/).

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [September 14, 2015, 5:02pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/3 "2015-09-14T17:02:42Z")

</div>

Using the python client there is an efficient "reindex" api[1] that can take a query as criteria to subset the data

[1] [https://elasticsearch-py.readthedocs.org/en/master/helpers.html#elasticsearch.helpers.reindex](https://elasticsearch-py.readthedocs.org/en/master/helpers.html#elasticsearch.helpers.reindex)

---

<div class="post-metadata">

### Author: ![michaellizhou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellizhou/32/4143_2.png) [@michaellizhou](https://discuss.elastic.co/u/michaellizhou)
#### Post date: [September 14, 2015, 5:19pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/4 "2015-09-14T17:19:30Z")

</div>

Thank you guys will look into it!

---

<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: [September 14, 2015, 9:01pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/5 "2015-09-14T21:01:05Z")

</div>

You can also use Logstash for this via [this](https://gist.github.com/markwalkom/8a7201e3f6ea4354ae06) method.  
There is also [snapshot & restore](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html).

---

<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:50pm UTC](https://discuss.elastic.co/t/export-es-indices-based-on-time/29269/6 "2017-07-05T23:50:23Z")

</div>


