DBAtlas · Database operations atlas

Automate snapshots and retention with SLM, monitor snapshot progress

ElasticsearchSnapshot

Command

# Take a snapshot every night at 01:30, keep for 30 days (at least 7, at most 60 snapshots):
PUT _slm/policy/gece-yedek
{
  "schedule": "0 30 1 * * ?",
  "name": "<gece-{now/d}>",
  "repository": "yedek_repo",
  "config": { "indices": ["*"], "include_global_state": true },
  "retention": { "expire_after": "30d", "min_count": 7, "max_count": 60 }
}
# Run the policy now and see success/failure statistics:
POST _slm/policy/gece-yedek/_execute
GET _slm/stats
# Snapshot in progress and per-shard progress:
GET _snapshot/yedek_repo/_current
GET _snapshot/yedek_repo/_status
GET _cat/snapshots/yedek_repo?v&s=end_epoch:desc
# Verify that the repository is writable from all nodes:
POST _snapshot/yedek_repo/_verify

What it does

Defines an SLM policy that takes snapshots on a cron schedule and deletes old ones according to a retention rule; shows per-shard progress of a running snapshot, past snapshots and repository reachability.

When to use it

When setting up regular backups, on an alert that the nightly snapshot failed, or when estimating when a long-running snapshot will finish.

Caution

The schedule is evaluated in UTC. If more than one cluster writes to the same repository, or the repository is registered as writable on another cluster, it can be corrupted; use readonly: true on the other clusters. Retention deletes only snapshots taken by SLM. include_global_state true can also restore templates and persistent cluster settings during a restore.

Open in DBAtlas →

Related