It is good to keep in mind that we do not cover the process of registering a snapshot repository, creating SLM policies, or taking snapshots. Explore our related posts on the topics to learn how to accomplish the above.”
Elasticsearch Show Available Snapshots
The first step is to locate the available snapshots in your cluster. Run the request as shown to get your available snapshots:
The above request should fetch all the available snapshots in your cluster and return them as a JSON object.
An example output is as shown:
"found-snapshots": {
"type": "gcs",
"uuid": "JhH0Ht5YT32KsjOeojp5Hw",
"settings": {
"bucket": "u37516e6a2fb2494499cbb13996a5f",
"aws_account": "operations-1-us-central1",
"use_for_peer_recovery": "true",
"client": "elastic-internal-93bb98",
"base_path": "snapshots/93bb98ab7e8c413bbb62abd77d602be8",
"region": "us-central1",
"email": "u37516e6a2fb2494499cbb13996a5f@cloud-production-storage.iam.gserviceaccount.com"
}
},
"sample_repo": {
"type": "gcs",
"uuid": "KkIOer35RIGEObFWAXC3_w",
"settings": {
"bucket": "u37516e6a2fb2494499cbb13996a5f",
"client": "elastic-internal-93bb98",
"base_path": "/snapshots/backups",
"compress": "true"
}
}
}
Once you locate the snapshot you wish to restore, we can proceed.
Elasticsearch Restore Index or Data Stream
Before restoring a specific index or data stream, ensure that it is included in the snapshot you wish to restore.
Start by deleting the index or data stream you wish to restore. This will prevent name collisions when restoring the data.
In this instance, we require to delete the netflix_copy index. We can delete the index by running the query:
The request above should drop the specified index or data stream from the cluster. Ensure that you have sufficient privileges on the target index before running the delete request.
To restore an index, use the syntax as shown:
{
"indices": "target_indicies"
}
For example, we can restore the netflix_copy index as shown in the request below:
{
"indices": "netflix_copy"
}
Once you run the query above, the request should restore the index from the snapshot:
"accepted": true
}
Elasticsearch Restore a Feature State
To restore a feature state from a given snapshot, we can run the request as;
{
"feature_states": [ "kibana" ]
}
The request above should restore the kibana feature from the specified snapshot.
Elasticsearch Restore Snapshot From Kibana
You can also perform snapshot restoration from the Kibana Dashboard. Navigate to Management -> Stack Management -> Snapshot and Restore.
Determine your target snapshot and select the “Restore” option.
Specify the restoration details such as global states, feature states, aliases etc.
Click Next to configure index settings during restoration. Here you can specify the index setting such as number of replicas, number of shards, etc. You can specify the settings of the index you wish to reset.
Click Next to review and start the restoration process.
Closing
Using this guide, you learned various methods and techniques for restoring an index, data stream or entire cluster from a snapshot.
Thanks for reading!!