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
