Configuring a Cloud Repository in Amazon S3
Before you begin
Make sure you have the necessary permissions and authentication set up for Elasticsearch to access your S3 bucket.
![*](icon_task_xpe.png)
To create an Elasticsearch snapshot repository in an Amazon S3 bucket
1. Run the following command:
curl -X PUT {BASIC_AUTH} "{es_endpoint}/_snapshot/{repoName}"
-H 'Content-Type: application/json' -d
'{
"type": "s3",
"settings": { "bucket": "{storageName}",
"base_path": "{basePath}",
"region": "{s3_bucket_region }",
"compress": true
}
}'
2. Replace the following placeholders in the command with actual values:
{BASIC_AUTH}. If your Elasticsearch cluster requires basic authentication, you should include the
-u or
--user option followed by the
username:password for authentication. For example,
-u myuser:mypassword.
{es_endpoint}. Replace this with the actual URL or endpoint of your Elasticsearch cluster. For example,
http://localhost:9200 if Elasticsearch is running locally, or a similar URL if it's hosted elsewhere.
{repoName}. Replace this with the name you want to give to your snapshot repository. This can be any unique name you choose.
{storageName}. Replace this with the name of your S3 bucket where you want to store Elasticsearch snapshots.
{basePath}. Optionally, specify a base path within the S3 bucket where you want to store snapshots. If you want to store snapshots in the root of the bucket, you can leave this empty.
{s3_bucket_region}. Replace this with the AWS region where your S3 bucket is located, such as
us-east-1 for the US East (N. Virginia) region.
"compress": true. Indicates that Elasticsearch should compress the snapshots before storing them in S3, which can save storage space.
A sample command with the placeholders replaced is as follows:
curl -X PUT -u myuser:mypassword "http://localhost:9200/_snapshot/my_snapshot_repo" -H 'Content-Type: application/json' -d '{
"type": "s3",
"settings": {
"bucket": "my-elasticsearch-snapshots",
"base_path": "elasticsearch-backups",
"region": "us-east-1",
"compress": true
}
}'
This command creates an Elasticsearch snapshot repository named my_snapshot_repo in the specified S3 bucket, using the provided AWS region for storage.