liveBook · Manning

_snapshot API

As explained in Elasticsearch in Action, Second Edition

The _snapshot API is an Elasticsearch REST API for creating, managing, and restoring snapshots in snapshot repositories.

The _snapshot API manages snapshot repositories and creates backups of Elasticsearch indexes, data streams, and cluster information. A typical production setup mounts shared storage on master and data nodes, configures path.repo, restarts the nodes, and registers the repository. section 14.4.2 section 14.4.3

Use the API to:

  • Register a filesystem repository by supplying the fs type and its mounted location. section 14.4.2
  • Create a manual snapshot with PUT _snapshot/repository/snapshot; omitting a body includes all indexes and data streams. section 14.4.3
  • Limit a snapshot with index names or glob patterns such as *movies* and *reviews*, and exclude patterns such as -*.old. section 14.4.3
  • Attach metadata such as a reason, incident identifier, and user to document why a snapshot was created. section 14.4.3

Back up production movie and review indexes

Register shared storage, then create a focused snapshot:\n\nPUT _snapshot/es_cluster_snapshot_repository\n{\n "type": "fs",\n "settings": {\n "location": "/volumes/es_snapshots"\n }\n}\n\nPUT _snapshot/es_cluster_snapshot_repository/prod_snapshots_with_metadata\n{\n "indices": ["*movies*", "*reviews*", "-*.old"],\n "metadata": {\n "reason": "user request",\n "incident_id": "ID12345",\n "user": "mkonda"\n }\n}\n\nThe first request registers the repository. The second backs up matching indexes, omits old indexes, and records operational context. section 14.4.2 section 14.4.3

Listing 14.4 Registering a filesystem-based snapshot repository
PUT _snapshot/es_cluster_snapshot_repository   #1
{
  "type": "fs",                                #2
  "settings": {
    "location": "/volumes/es_snapshots"        #3
  }
}

Inspect the complete filesystem-based repository registration request, including the repository name, type, and location. section 14.4.2

Listing 14.6 Creating snapshots with specific indexes
PUT _snapshot/es_cluster_snapshot_repository/custom_prod_snapshots
{
  "indices": ["*movies*","*reviews*"]   #1
}

Inspect a focused snapshot request that selects indexes with glob patterns. section 14.4.3

Listing 14.7 Adding custom details to the snapshot
PUT _snapshot/es_cluster_snapshot_repository/prod_snapshots_with_metadata
{
  "indices": ["*movies*","*reviews*", "-*.old"],  #1
  "metadata":{                                    #2
    "reason":"user request",
    "incident_id":"ID12345",
    "user":"mkonda"
  }
}

Inspect a production-style snapshot request combining index exclusions with incident metadata. section 14.4.3

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Covers mounted storage, path.repo configuration, repository registration, index filtering, exclusions, and metadata, without detailing restoration.
Examples
Uses a filesystem repository, production snapshot, movie and review index patterns, old-index exclusions, and incident metadata.
What it assumes
Assumes shared storage, path.repo configuration, and node restarts; teaches repository registration and snapshot requests.
What you can do after
Operate/configure repositories and create full or selective snapshots through REST requests.
How it connects
Links snapshot repositories, snapshots, restores, indexes, data streams, cluster information, and Kibana Console.

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.