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
