# How to backup all indices older than a date using Curator plugin?

**URL:** <https://discuss.elastic.co/t/how-to-backup-all-indices-older-than-a-date-using-curator-plugin/68007>\
**Category:** Elasticsearch\
**Created:** [December 5, 2016, 9:15am UTC](https://discuss.elastic.co/t/how-to-backup-all-indices-older-than-a-date-using-curator-plugin/68007 "2016-12-05T09:15:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [December 5, 2016, 9:15am UTC](https://discuss.elastic.co/t/how-to-backup-all-indices-older-than-a-date-using-curator-plugin/68007/1 "2016-12-05T09:15:32Z")

</div>

Hi,

It will be great if @theuntergeek can help me in this.

I have a curator action file like this;

```
actions:
  1:
    action: snapshot
    description: >-
    options:
      repository: mybackup
      name: myindexa-%Y%m%d%H%M%S
      ignore_unavailable: False
      include_global_state: True
      partial: False
      wait_for_completion: True
      skip_repo_fs_check: False
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: myindexa-
      exclude:
    - filtertype: age
      source: creation_date
      direction: older
      timestring: '%Y-%m-%d'
      unit: days
      unit_count: 5
      exclude:

```

I follow an index pattern having name followed by a hyphen and date like;

- myindexa-2016-12-01
- myindexb-2016-12-01
- myindexc-2016-12-01
- myindexd-2016-12-01
- myindexe-2016-12-01  
etc

I want to take snapshot of all these indices at once. My current action file take snapshot of only one index (myindexa). How can I do this?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [December 5, 2016, 4:07pm UTC](https://discuss.elastic.co/t/how-to-backup-all-indices-older-than-a-date-using-curator-plugin/68007/2 "2016-12-05T16:07:20Z")

</div>

There are several ways to approach this, but it matters what you actually want in the snapshots.

Do you _only_ want to snapshot indices with a year-month-day pattern in the name? Or are there some indices you want to snapshot that don't have that pattern? Because you have `source: creation_date`, Curator will ignore `timestring: '%Y-%m-%d'`. That line won't matter in your `age` filter.

If all of the indices you wanted to snapshot have a year-month-day pattern, you could simply exclude the `prefix` filter, and change to `source: name`.

```auto
    filters:
    - filtertype: age
      source: name
      timestring: '%Y-%m-%d'
      direction: older
      unit: days
      unit_count: 5

```

You could also filter by timestring _pattern_ but not by the date indicated by the `timestring` in the index name (and still use the `creation_date`) this way:

```auto
    filters:
    - filtertype: pattern
      kind: timestring
      value: '%Y-%m-%d'
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 5

```

This filter block will only act on indices with a year-month-day pattern, and only those with a `creation_date` older than 5 days ago.

If you need to match certain patterns, you could also use a `regex` pattern kind:

```auto
    filters:
    - filtertype: pattern
      kind: regex
      value: '^(myindexa-|myindexb-|myindexc-|myindexn-).*$'
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 5

```

This filter block will only act on indices that begin with `myindexa-`, `myindexb-`, `myindexc-`, or `myindexn-`, and have a `creation_date` older than 5 days.

Hopefully this gives you some ideas. If you have more questions, feel free to ask!

---

<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 2, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-to-backup-all-indices-older-than-a-date-using-curator-plugin/68007/3 "2017-01-02T16:07:34Z")

</div>

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