# Deleting Old Snapshots

**URL:** <https://discuss.elastic.co/t/deleting-old-snapshots/134085>\
**Category:** Elasticsearch\
**Created:** [May 31, 2018, 4:06pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085 "2018-05-31T16:06:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MPurcell](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@MPurcell](https://discuss.elastic.co/u/MPurcell)\
**Post date:** [May 31, 2018, 4:06pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/1 "2018-05-31T16:06:56Z")

</div>

Periodically over the last year or two, I have taken snapshots of different indices. Some of these I have recorded in a spreadsheet, some I have not. Now, I would like to delete all snapshots older then 90 days that do not include the prefix 'citydirectory', but without having to go through the spreadsheet and deleting them one by one. Therefore by these requirements: a snapshot that's 6 months old called 'citydirectory\_v1' would not be deleted, but another snapshot 'example2' that's also 6 months old would be deleted. What is the best way to do something like this? I was thinking of writing a python script that returns all snapshots on s3, but this may not include the dates. I also think there is an intuitive was to do this in Elasticsearch, or as part of the ElasticStack, although I can't remember what it is. If you think of a better way to do this, please let me know. Thank you.

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [June 1, 2018, 6:42am UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/2 "2018-06-01T06:42:09Z")

</div>

you could try Elastic Curators delete Snapshot funtionality

[https://www.elastic.co/guide/en/elasticsearch/client/curator/current/delete\_snapshots.html#delete\_snapshots](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/delete_snapshots.html#delete_snapshots)

---

<div class="post-metadata">

**Author:** ![MPurcell](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@MPurcell](https://discuss.elastic.co/u/MPurcell)\
**Post date:** [June 4, 2018, 2:22pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/3 "2018-06-04T14:22:58Z")

</div>

Hey @Shaoranlaos, I'm taking a look at curator now. I will post my results here later. Thanks for the tip!

---

<div class="post-metadata">

**Author:** ![MPurcell](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@MPurcell](https://discuss.elastic.co/u/MPurcell)\
**Post date:** [June 4, 2018, 5:43pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/4 "2018-06-04T17:43:29Z")

</div>

Hi @Shaoranlaos I have setup curator and have my script -- it's show below:

Curator.yml

> client:  
> hosts:  
> - 'a data node'  
> port: 9200  
> url\_prefix:  
> use\_ssl: False  
> certificate:  
> client\_cert:  
> client\_key:  
> ssl\_no\_validate: False  
> http\_auth:  
> timeout: 30  
> master\_only: False
> 
> logging:  
> loglevel: INFO  
> logfile: D:\CuratorLogs\logs.txt  
> logformat: default  
> blacklist: ['elasticsearch', 'urllib3']

delete\_old\_snapshots.yml

> actions:  
> 1:  
> action: delete\_snapshots  
> description: \>-  
> Delete snapshots from the selected repository older than 100 days  
> (based on creation\_date), for everything but 'citydirectory-' prefixed snapshots.  
> options:  
> repository: 'dcs-elastic-snapshot'  
> disable\_action: False  
> filters:  
> - filtertype: pattern  
> kind: prefix  
> value: citydirectory-  
> exclude: True  
> - filtertype: age  
> source: creation\_date  
> direction: older  
> unit: days  
> unit\_count: 100

For some reason I keep getting the exception 'Failed to complete action: delete\_snapshots. \<class 'curator.exceptions.FailedExecution'\>: Unable to verify existence of repository dcs-elastic-snapshot  
'. Any idea why it's not finding the correct s3 repository?

---

<div class="post-metadata">

**Author:** ![MPurcell](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@MPurcell](https://discuss.elastic.co/u/MPurcell)\
**Post date:** [June 4, 2018, 7:45pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/5 "2018-06-04T19:45:45Z")

</div>

I figured it out. In repository - put the name you registered the s3 bucket as, not as what it appears in s3 if they differ. So for me I registered my s3 bucket under 'dcselasticsnapshot' rather then what is appears in s3 'dcs-elastic-snapshot'.

---

<div class="post-metadata">

**Author:** ![MPurcell](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@MPurcell](https://discuss.elastic.co/u/MPurcell)\
**Post date:** [June 4, 2018, 8:34pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/6 "2018-06-04T20:34:18Z")

</div>

fyi this solves my question, so marking this as the correct answer.

---

<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 2, 2018, 8:34pm UTC](https://discuss.elastic.co/t/deleting-old-snapshots/134085/7 "2018-07-02T20:34:28Z")

</div>

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