Skip to main content

ElasticSearch Backup/Restore from S3

Steps to restore an ElasticSearch Snapshot from an S3 backup:

*make sure same version for less issues

  1. Install S3 plugin

  2. allow insecure settings (on local ElasticSearch instance)
    a. open ProgramData -> Elastic -> ElasticSearch -> config -> jvm.options
    b. edit the file and add the line "-Des.allow_insecure_settings=true" to the bottom.
    c. restart the ElasticSearch service.

  3. Register the S3 bucket as a snapshot repository
    a. Do a PUT to "http://localhost:9200/_snapshot/s3_repository " with a body: {
    "type": "s3",
    "settings": {
    "bucket": "elasticsearch-monitor",
    "region": "us-east-1",
    "access_key": "{access_key}",
    "secret_key": "{key_secret}"
    }
    }

  4. Create the snapshot
    a. Do a POST "http://localhost:9200/_snapshot/s3_repository/{snapshot_name}?wait_for_completion=true " with a body:
    {
    "type": "s3",
    "settings": {
    "bucket": "efc-elasticsearch-export",
    "region": "us-east-1",
    "access_key": "{access_key}",
    "secret_key": "{key_secret}"
    }
    }

  5. Register S3 repository with hosted ElasticSearch: Following this article  or article2 
    a. Once you have the role arn and S3 access key and secret, do a PUT request to the AWS ElasticSearch instance using Postman.
    b. Postman has the ability to do a "Signed Request" which is important for this PUT request to complete successfully. You do this by going to the Authorization tab, selecting Type: AWS Signature. Enter the access key, and secret, region (probably us-east-1) and Service Name (es).
    c. The URL and body are as follows:
    URL: https://{your url}.us-east-1.es.amazonaws.com/_snapshot/s3_repository?pretty&verify=false
    Body (JSON): {
    "type": "s3",
    "settings": {
    "bucket": "efc-elasticsearch-export",
    "role_arn": "arn:aws:iam::{your arn}:role/es-to-s3-repository-staging-role",
    "region": "us-east-1"
    }
    }
    d. Validate snapshot is available: GET "https://{yoururl}.us-east-1.es.amazonaws.com/_snapshot/s3_repository/_all"
    e. Restore the snapshot with a POST "https://{your_url}.us-east-1.es.amazonaws.com/_snapshot/s3_repository/{snapshot_name}/_restore"