How to Create & Manage OpenSearch Snapshots using AWS S3

June 23, 2025 • 2 min read

As a developer working with OpenSearch on AWS, you’ll inevitably need to backup your data, migrate indices between clusters, or recover from the occasional mishap. OpenSearch S3 snapshots are your safety net – they let you create point-in-time backups stored in Amazon S3 and perform operations like restoring specific indices or merging data between clusters. Think of this as your essential toolkit for keeping your search data safe and manageable in AWS environments.

Note that while you can do most of the OpenSearch commands via curl, for this article I’m going to assume you have access to Dev Tools within your OpenSearch cluster. This just makes the examples a little cleaner instead of having to include things like auth and headers.

Prerequisites: IAM Configuration

1. Create IAM Role

# example role creation using the AWS CLI
aws iam create-role \
  --role-name opensearch-s3-repository \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [{
      "Effect": "Allow",
      "Principal": {"Service": "es.amazonaws.com"},
      "Action": "sts:AssumeRole"
    }]
  }'

2. Create an IAM Policy

This can be a standalone or inline policy attached to the role created above. Note this assumes the S3 bucket name is opensearch-snapshots

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": ["s3:ListBucket"],
      "Effect": "Allow",
      "Resource": ["arn:aws:s3:::opensearch-snapshots"]
    },
    {
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject",
        "iam:PassRole"
      ],
      "Effect": "Allow",
      "Resource": ["arn:aws:s3:::opensearch-snapshots/*"]
    }
  ]
}

3. Create S3 Bucket for the Snapshots

aws s3 mb s3://opensearch-snapshots --region us-east-1

Register Snapshot Repository

Register the AWS S3 bucket as a snapshot repository. For your use-case, you’ll need to update the bucket and role_arn properties

PUT /_snapshot/s3-snapshot
{
  "type": "s3",
  "settings": {
    "bucket": "opensearch-snapshot",
    "endpoint": "s3.amazonaws.com",
    "role_arn": "arn:aws:iam::12345678910:role/opensearch-s3-repository"
  }
}

Create and Monitor Snapshots

# Create Snapshot -
PUT /_snapshot/s3-snapshot/2025-07-02

# Check Snapshot Status
GET /_snapshot/s3-snapshot/_status

Restore Indices from Snapshots

1. List Available Snapshots

# List all repositories
GET /_snapshot/_all?pretty

# List snapshots in repository
GET /_snapshot/s3-snapshot/_all?pretty

2. Restore Specific Index

Note: Ensure the target index doesn’t already exist.

POST /_snapshot/s3-snapshot/2025-07-02/_restore
{
  "indices": "target-index-name",
  "ignore_unavailable": false,
  "include_global_state": false
}