# Elasticsearch take snapshot then clean indices which older than 7 days

**URL:** <https://discuss.elastic.co/t/elasticsearch-take-snapshot-then-clean-indices-which-older-than-7-days/257957>\
**Category:** Elasticsearch\
**Created:** [December 8, 2020, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-take-snapshot-then-clean-indices-which-older-than-7-days/257957 "2020-12-08T09:09:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KA3AXCTAH](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@KA3AXCTAH](https://discuss.elastic.co/u/KA3AXCTAH)\
**Post date:** [December 8, 2020, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-take-snapshot-then-clean-indices-which-older-than-7-days/257957/1 "2020-12-08T09:09:15Z")

</div>

I have Elasticsearch 7.4.1 cluster for storing logs, and i have this SLM pattern applied in my cluster

```auto
curl -X PUT "afghanistan-01.elastic:9200/_slm/policy/nightly-snapshots?pretty" -H 'Content-Type: application/json' -d'
{
  "schedule": "0 30 1 * * ?", 
  "name": "<nightly-snap-{now/d}>", 
  "repository": "backup_repository",
  "config": { 
    "indices": ["*"] 
  }
}

```

so this SLM takes snapshot daily at 01:30 AM. And i want to delete indices which is older than 7 days after the successful snapshot completion so is there any way to do that using the policies? i know how to do it using Bash, but i think it's better to use internal mechanism to do this

---

<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:** [January 5, 2021, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-take-snapshot-then-clean-indices-which-older-than-7-days/257957/2 "2021-01-05T09:09:15Z")

</div>

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