liveBook · Manning

Snapshot lifecycle policy

As explained in Elasticsearch in Action, Second Edition

A snapshot lifecycle policy is a configuration that specifies how Elasticsearch schedules, creates, and retains snapshots.

A snapshot lifecycle policy automates nightly backups of selected Elasticsearch indexes, stores them in a registered repository, and removes older snapshots after a defined period. section 14.4.6

Listing 14.11 Creating a policy for scheduled snapshots
PUT _slm/policy/prod_cluster_daily_backups         #1
{
  "name":"<prod_daily_backups-{now/d}>",           #2
  "schedule": "0 0 0 * * ?",                       #3
  "repository": "es_cluster_snapshot_repository",  #4
  "config": { 
    "indices":["*movies*", "*reviews*"],           #5
    "include_global_state": false                  #6
  },
  "retention":{
    "Expire_after":"7d"                            #7
  }
}

Creates a daily movie-and-review backup policy: date math generates unique names, the cron expression runs at midnight, and retention expires snapshots after seven days. section 14.4.6

The configuration combines these operational choices:

  • A unique policy name identifies the stored SLM policy. section 14.4.6
  • A cron schedule determines when snapshot creation begins. section 14.4.6
  • Index patterns and include_global_state control what the snapshot contains. section 14.4.6
  • Retention removes snapshots older than the configured period; a registered repository is required first. section 14.4.6

Run a scheduled snapshot immediately

POST _slm/policy/prod_cluster_daily_backups/_execute manually starts the policy instead of waiting for its next scheduled run. section 14.4.6

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains policy fields, date-math names, cron scheduling, index selection, global state, retention, and manual execution.
Examples
Uses nightly movie and review backups, date-based snapshot names, seven-day retention, and manual policy execution.
What it assumes
Requires a registered snapshot repository before creating a snapshot lifecycle policy.
What you can do after
Operate/configure scheduled backups with Elasticsearch’s _slm API and execute a policy on demand.
How it connects
Connects Elasticsearch snapshots with snapshot lifecycle management, repositories, cron expressions, retention, and date math.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.