# Keep active index while deleting old indices with ILM

**URL:** <https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [April 14, 2021, 1:52pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119 "2021-04-14T13:52:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [April 14, 2021, 1:52pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/1 "2021-04-14T13:52:24Z")

</div>

We rebuild the same index regularly (multiple times per day) to keep our data up to date. This way we quickly generate a lot of old indices.

So we thought about removing them with a policy (ILM) which deletes old indices let's say 7 days after index creation.

This works fine but the only problem with it is that it could potentially delete the current (active) index. In a hypothetical scenario when the index rebuild would stop for 7 days it would delete the currently active index.

So my question is whether there is a way to keep the active index from being deleted. We have an alias on the current index. Is there a way to protect it from deletion and when switching to the new index we can switch the protection over to the newly created index?

---

<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:** [April 14, 2021, 11:22pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/2 "2021-04-14T23:22:28Z")

</div>

No there's not, it'll run based on the policy irrespective of if it's being used.

---

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [April 19, 2021, 12:51pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/3 "2021-04-19T12:51:19Z")

</div>

Ok, thanks for your confirmation Mark.

Do you know of another way to implement/configure such behaviour (keep active index and only delete old ones) within Elasticsearch itself? Or do we have to implement it ourselves?

---

<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:** [April 19, 2021, 9:03pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/4 "2021-04-19T21:03:38Z")

</div>

That'd be DIY.

---

<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:** [April 19, 2021, 9:03pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/5 "2021-04-19T21:03:59Z")

</div>

That'd be DIY.

---

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [April 20, 2021, 1:46pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/6 "2021-04-20T13:46:04Z")

</div>

Alright. Thank you!

---

<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:** [May 18, 2021, 1:46pm UTC](https://discuss.elastic.co/t/keep-active-index-while-deleting-old-indices-with-ilm/270119/7 "2021-05-18T13:46:57Z")

</div>

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