# Why Elasticsearch delete repository API only removes reference

**URL:** <https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660>\
**Category:** Elasticsearch\
**Created:** [October 1, 2021, 8:27am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660 "2021-10-01T08:27:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepika\_Dhiman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepika_dhiman/32/78541_2.png) [@Deepika\_Dhiman](https://discuss.elastic.co/u/Deepika_Dhiman)\
**Post date:** [October 1, 2021, 8:27am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/1 "2021-10-01T08:27:05Z")

</div>

I am using Elasticsearch API to delete the Elasticsearch repository and Elasticsearch locations. But in both cases, Physical folders remain intact in the file system.  
I read in the documentation that delete API only removes the references and keeps the physical files untouched.  
Why Elasticsearch does not delete the repository/location from the physical location?  
Does it expect clients to do it?  
Are there any APIs available from Elastic to delete the repository and location from the file system?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 1, 2021, 9:18am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/2 "2021-10-01T09:18:20Z")

</div>

Welcome!

Removing a repository does not remove the snapshots.

So you need to remove the snapshots first and then you can remove the repository.

---

<div class="post-metadata">

**Author:** ![Deepika\_Dhiman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepika_dhiman/32/78541_2.png) [@Deepika\_Dhiman](https://discuss.elastic.co/u/Deepika_Dhiman)\
**Post date:** [October 1, 2021, 9:21am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/3 "2021-10-01T09:21:47Z")

</div>

ok, sure. So, if I remove the snapshot first and then remove the repository will it delete the repository from the file system as well?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 1, 2021, 9:51am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/4 "2021-10-01T09:51:37Z")

</div>

It won't cleanup everything as I believe that some few metadata files might still exist.

But what are you trying to solve?

---

<div class="post-metadata">

**Author:** ![Deepika\_Dhiman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepika_dhiman/32/78541_2.png) [@Deepika\_Dhiman](https://discuss.elastic.co/u/Deepika_Dhiman)\
**Post date:** [October 1, 2021, 10:02am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/5 "2021-10-01T10:02:32Z")

</div>

I need to delete the repository/location folder from the file system after the repository/location is deleted from Elasticsearch.  
But like you said, Elastic leaves some metadata files. So, could it be useful in the future? Should I be worried before deleting the folder from the file system manually?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 1, 2021, 1:28pm UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/6 "2021-10-01T13:28:42Z")

</div>

Just `rm -r` the dir and you'll be done.

---

<div class="post-metadata">

**Author:** ![Deepika\_Dhiman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepika_dhiman/32/78541_2.png) [@Deepika\_Dhiman](https://discuss.elastic.co/u/Deepika_Dhiman)\
**Post date:** [October 4, 2021, 4:43am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/7 "2021-10-04T04:43:05Z")

</div>

Sure, Thanks for the help @dadoonet.

---

<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:** [November 1, 2021, 4:43am UTC](https://discuss.elastic.co/t/why-elasticsearch-delete-repository-api-only-removes-reference/285660/8 "2021-11-01T04:43:45Z")

</div>

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