Backup/Restore elasticsearch between aws accounts

Ahmet Kaftan
cloudnesil
Published in
1 min readJun 27, 2019

This article is about backing up and restoring elasticsearch between aws accounts. Since you can find plenty of resources online about installing s3 plugin, creating iam user, creating iam role for s3 access. I will focus on key points of backup and restore.

  1. Create snapshot repository on where you want to take backup.
```
PUT /_snapshot/$snapshot_repository?verify=false&pretty
{
"type": "s3",
"settings": {
"bucket": "$bucket_name",
"region": "eu-central-1"
}
}
```

2. Create backup

```
PUT /_snapshot/$snapshot_repository/$snapshot_name
```

3. Create secure credentials on elasticsearch-data nodes

```
bin/elasticsearch-keystore add s3.client.default.access_key
bin/elasticsearch-keystore add s3.client.default.secret_key
```

4. Reload security settings.

```
POST _nodes/reload_secure_settings
```

5. Create snapshot repository on where you want to restore backup.

```
PUT /_snapshot/$snapshot_repository?verify=false&pretty
{
"type": "s3",
"settings": {
"bucket": "$bucket_name",
"region": "eu-central-1"
}
}
```

6. Delete existing indexes

```
DELETE /_all
```

7. Close existing indexes

```
POST $index_to_be_closed/_close
```

8. Restore snapshot

```
POST /_snapshot/$snapshot_repository/$snapshot_name/_restore
```

--

--