Useful link, thanks for sharing Mark.
I have made full poof steps for version 6.8. here are those.
Taking a snapshot of on-prem to S3
Custom Policy: We will create a custom policy with the following policy document:
{
"Statement": [
{
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:ListBucketMultipartUploads",
"s3:ListBucketVersions"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::S3-BUCKET-NAME"
]
},
{
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::S3-BUCKET-NAME/*"
]
}
],
"Version": "2012-10-17"
}
IAM User: Then, we will create an IAM user attaching the custom policy. We need to collect the ACCESS_KEY_ID and SECRET_ACCESS_KEY.
S3 Elasticsearch Plugin Installation :
Install S3 plugin:
cd /usr/share/elasticsearch
sudo bin/elasticsearch-plugin install --batch repository-s3
For easy setup, set -Des.allow_insecure_settings=true to /etc/elasticsearch/jvm.options.
Snapshot Repository Registration :
curl -X PUT "localhost:9200/_snapshot/REPOSITORY_NAME?pretty" -H 'Content-Type: application/json' -d'
{
"type": "s3",
"settings": {
"bucket": "S3-BUCKET-NAME",
"region": "AWS_REGION",
"access_key": "ACCESS_KEY_ID",
"secret_key": "SECRET_ACCESS_KEY"
}
}
'
Taking Snapshot :
We can take a snapshot from running elasticsearch cluser by the following command, Here, SNAPSHOT_NAME is unique per REPOSITORY_NAME.
curl -X PUT "localhost:9200/_snapshot/REPOSITORY_NAME/SNAPSHOT_NAME?wait_for_completion=true&pretty" -H 'Content-Type:application/json' -d'
{
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false
}
'
Example
Registering snapshot for on-prem
curl -XPUT "localhost:9200/_snapshot/tenant-repo?pretty" -H 'Content-Type: application/json' -d'
{
"type": "s3",
"settings": {
"bucket": "tenant-snapshot",
"region": "us-west-2",
"access_key": "AKIAUZIOM7PN2URJHIPO",
"secret_key": "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"
}
}
'
Taking a snapshot(method-1)
curl -X PUT "localhost:9200/_snapshot/tenant-repo/tenant-snap01?wait_for_completion=true&pretty" -H 'Content-Type:application/json' -d'
{
"indices": "index_1,index_2",
"ignore_unavailable": true,
"include_global_state": false
}
'
Taking a snapshot(method-2)
curl -XPUT 'localhost:9200/_snapshot/tenant-repo/tenant-snap01'
To restore all the indices to target ES cluster:
Another process of repository registration and restoration.
Thanks.