# Curator is deleting all snapshots

**URL:** <https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833>\
**Category:** Elasticsearch\
**Created:** [December 10, 2015, 6:10am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833 "2015-12-10T06:10:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [December 10, 2015, 6:10am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/1 "2015-12-10T06:10:51Z")

</div>

Hi there,

I am using ElasticSearch 1.5.0 and curator 3.2.3.  
I recently created a script to be executed as daily cron job which deletes all snapshots older than a week. But when executed, it deletes each and every snapshot in my S3 repository.

Following is the code snippet used for this:  
`/usr/local/bin/curator --timeout 21600 delete snapshots --repository $RESPOSITORY_NAME $snapshot_delete_string`  
where RESPOSITORY\_NAME is the name of the S3 repository I am using and snapshot\_delete\_string is of the format [--snapshot snapshot\_name]+

The log for the last execution of this script is below:  
`2015-12-10 04:00:04,825 INFO Job starting: delete snapshots 2015-12-10 04:00:08,564 INFO Adding curator-20151203150012 from command-line argument 2015-12-10 04:00:08,564 INFO Adding curator-20151203180012 from command-line argument 2015-12-10 04:00:08,564 INFO Adding curator-20151203210011 from command-line argument 2015-12-10 04:00:08,564 INFO Deleting snapshot curator-20151203150012 2015-12-10 04:03:14,586 INFO Deleting snapshot curator-20151203180012 2015-12-10 04:05:54,822 INFO Deleting snapshot curator-20151203210011 2015-12-10 04:08:21,964 INFO Deleting snapshot curator-20151204000013 2015-12-10 04:10:57,958 INFO Deleting snapshot curator-20151204030013 2015-12-10 04:13:31,731 INFO Deleting snapshot curator-20151204060013 .......... and may other snapshots, skipped here 2015-12-10 05:17:07,989 INFO Deleting snapshot curator-20151210030012 2015-12-10 05:18:59,970 INFO Job completed successfully`

---

<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:** [December 10, 2015, 6:29am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/2 "2015-12-10T06:29:07Z")

</div>

You did not set older than or newer than?

[https://www.elastic.co/guide/en/elasticsearch/client/curator/current/snapshot-selection.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/snapshot-selection.html)

---

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [December 10, 2015, 6:37am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/3 "2015-12-10T06:37:03Z")

</div>

When I started coding this, I was not aware that those options could be used with "delete" also and not just "show". So, I was first using the --older-than option with show, getting the list of snapshots to be deleted and then deleting them using --snapshot \<snapshot\_name\> option.

Will using these options directly with "delete" help?

---

<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:** [December 10, 2015, 7:14am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/4 "2015-12-10T07:14:07Z")

</div>

If you don't tell curator what to delete, I guess it deletes all snapshots matching the name you gave.

---

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [December 10, 2015, 7:19am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/5 "2015-12-10T07:19:59Z")

</div>

I gave exact names to curator, no regex.  
Please have another look at the log I provided earlier. It starts with stating the three snapshot names that were provided to it. But then goes on deleting all the snapshots in the repository.

---

<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:** [December 10, 2015, 7:34am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/6 "2015-12-10T07:34:14Z")

</div>

You're right. Using `--snapshot` ignores all other parameters.

I'd open an issue in curator project.

---

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [December 10, 2015, 7:46am UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/7 "2015-12-10T07:46:02Z")

</div>

I just changed my cleanup script to make use of `--older-than` option instead of `--snapshot` option and things started to work as expected. Only the intended snapshots are getting deleted. Thanks for pointing me in the right direction.

---

<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:32pm UTC](https://discuss.elastic.co/t/curator-is-deleting-all-snapshots/36833/8 "2017-07-05T23:32:08Z")

</div>


