Elasticsearch snapshots to S3 are the standard durability story — they’re incremental, deduplicated at the segment level, and survive cluster loss. This article configures the repository-s3 plugin, registers an S3-backed repository, takes a snapshot, restores selectively, and automates the cadence via SLM (Snapshot Lifecycle Management). Audience is operators putting durable backups on an Elasticsearch 8.x cluster.
How to verify
After setup, confirm the repository is registered and snapshots are succeeding:
curl -sk -u elastic:"$PW" 'https://es:9200/_cat/repositories?v'
curl -sk -u elastic:"$PW" 'https://es:9200/_snapshot/_status'
curl -sk -u elastic:"$PW" 'https://es:9200/_snapshot/sh-backup/_all?pretty' | jq '.snapshots[] | {snapshot, state, duration_in_millis}'
curl -sk -u elastic:"$PW" 'https://es:9200/_slm/policy?pretty'
curl -sk -u elastic:"$PW" 'https://es:9200/_slm/stats?pretty'
Healthy: repository status available, latest snapshot SUCCESS, SLM policy has a last_success newer than the schedule period.
What’s happening
A snapshot is a copy of all segment files referenced by an index at a point in time, plus the cluster metadata. Subsequent snapshots only upload segments that don’t already exist in the repository — incremental cost is low. Internally, snapshots are flat files in S3 with index-N metadata files and __N-prefixed shard data.
The repository-s3 plugin ships with Elasticsearch 8.x by default — no separate install. It authenticates to AWS via:
- Instance IAM role (on EC2) — preferred for AWS-native deployments.
- Static keys in the keystore — for non-AWS hosts (Wasabi, MinIO, on-prem).
- EKS IRSA / Pod Identity — for Elasticsearch on Kubernetes.
SLM is the scheduling layer: you define a cron-style schedule, retention rules, and the indices to include. It runs in the cluster and reports via the SLM stats API.
The procedure
1. Create the S3 bucket and IAM policy. The plugin needs s3:ListBucket, s3:GetObject, s3:PutObject, s3:DeleteObject, s3:GetBucketLocation, s3:AbortMultipartUpload:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetBucketLocation", "s3:ListBucket"],
"Resource": "arn:aws:s3:::sh-es-backups"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts"],
"Resource": "arn:aws:s3:::sh-es-backups/*"
}
]
}
Attach to the EC2 instance role (or seed the keys for non-AWS targets — see step 2).
2. (Non-AWS only) Add S3-compatible credentials to the keystore on every Elasticsearch node:
sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key
sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key
sudo systemctl restart elasticsearch
For MinIO or other S3-compatible endpoints, also set endpoint, protocol, path_style_access: true in repository settings.
3. Register the repository:
curl -sk -u elastic:"$PW" -X PUT 'https://es:9200/_snapshot/sh-backup' \
-H 'Content-Type: application/json' \
-d '{
"type": "s3",
"settings": {
"bucket": "sh-es-backups",
"region": "ca-central-1",
"base_path": "prod-cluster/",
"compress": true,
"chunk_size": "256mb",
"server_side_encryption": true,
"storage_class": "intelligent_tiering"
}
}'
Verify with _verify:
curl -sk -u elastic:"$PW" -X POST 'https://es:9200/_snapshot/sh-backup/_verify'
A successful verify returns the cluster nodes that wrote test files to S3.
4. Take a snapshot manually:
SNAP=$(date -u +%Y%m%d-%H%M)
curl -sk -u elastic:"$PW" -X PUT "https://es:9200/_snapshot/sh-backup/${SNAP}?wait_for_completion=false" \
-H 'Content-Type: application/json' \
-d '{
"indices": "*,-.security*,-.kibana*",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {"taken_by": "manual", "reason": "pre-upgrade"}
}'
Excluding system indices (-.security*, -.kibana*) is the safer default — those follow their own backup paths and can confuse a restore.
5. Automate with SLM:
curl -sk -u elastic:"$PW" -X PUT 'https://es:9200/_slm/policy/six-hourly' \
-H 'Content-Type: application/json' \
-d '{
"schedule": "0 30 */6 * * ?",
"name": "<sh-{now/d}->",
"repository": "sh-backup",
"config": {
"indices": ["logs-*", "metrics-*", "products-*"],
"ignore_unavailable": true,
"include_global_state": false,
"partial": false
},
"retention": {
"expire_after": "14d",
"min_count": 12,
"max_count": 60
}
}'
# Force the first run
curl -sk -u elastic:"$PW" -X POST 'https://es:9200/_slm/policy/six-hourly/_execute'
The cron is Quartz-style. Retention keeps at least 12 (last 3 days at 6-hourly cadence) and at most 60 snapshots, expiring after 14 days.
6. Restore selectively:
curl -sk -u elastic:"$PW" -X POST 'https://es:9200/_snapshot/sh-backup/sh-2026.06.02-bk5/_restore' \
-H 'Content-Type: application/json' \
-d '{
"indices": "products-2026.06.*",
"rename_pattern": "products-(.+)",
"rename_replacement": "restored-products-$1",
"include_global_state": false
}'
Renaming on restore avoids overwriting a live index. Once the renamed index is verified, the application is switched via aliases and rollover.
Operational notes
- Test restores quarterly. A snapshot that hasn’t been restored is hope, not a backup.
- Repository version lock-in. A snapshot taken in 8.13 can be restored to 8.13, 8.14, or later; not to 8.12. Plan upgrades so backups remain usable.
max_restore_bytes_per_seccaps restore throughput per node. Default is 40 MB/s — bump to 200mb if your S3 + network can keep up and you need fast recovery.- Concurrent snapshots are serialized.
cluster.max_concurrent_snapshot_operations: 1is the safe default — running two at once can starve cluster IO. - S3 bucket lifecycle policies and snapshots don’t mix. Don’t auto-delete S3 objects — Elasticsearch tracks segment references and a deleted “old” object can break a “new” snapshot. Use SLM retention only.
In the engagements we run, snapshots are the second line of defense after replicas — they survive cluster loss, accidental delete, and bad upgrades. We run SLM with retention measured in weeks, restore-test in a staging cluster monthly, and document the recovery RPO/RTO in the runbook. See /en/services/managed-operations/ for how we operate search clusters with durable backups as part of the platform.