Elastic Search

Elasticsearch Verify the Snapshot Repository

In this short tutorial, we will learn how to use the verify snapshot API in Elasticsearch to verify if a given snapshot is functional.

It is a good practice to ensure that a snapshot is functional before creating any snapshots in the repository.

Request Syntax

We can access the API endpoint with a request as shown in the following syntax:

POST /_snapshot/<repository>/_verify

Depending on the cluster configuration, the request may require the “manage” privileges on the target cluster.

Request Path Parameters

The request supports the following path parameters:

  1. <repository> – This specifies the name of the repository that you wish to verify. The repository must exist before running the verify API.

Request Query Parameters

You can also specify the following parameters in your query:

  1. Master_timeout – This parameter allows you to specify the time to wait for the connection to the master node before the request fails and returns an error. By default, the request fails after 30 seconds.
  2. timeout – Allows you to define the period to wait for a response. Similarly, the request fails if the defined timeout is elapsed before a response.

Response Body

Once you make a request to the verify API, Elasticsearch returns a response which is comprised of the following properties:

  1. nodes – This is a node object containing the nested information such as:

      a. node_id – Shows the information about a node connected to the specified repository. Shows the ID of the target node.

Elasticsearch Create Repository

To best illustrate how to use the Elasticsearch verify snapshot API, let us create a testing repository.

The following query shows how to create a repository using the Google Cloud Storage platform:

curl -XPUT "http://localhost:9200/_snapshot/testing_repo" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
"type": "gcs",
"settings": {
"client": "elastic-internal-93bb98",
"bucket": "u37516e6a2fb2494499cbb13996a5f",
"base_path": "snapshots/testing",
"compress": true
}
}'

The previous query should create a repository under the name “testing_repo”.

{
"acknowledged": true
}

We can check if the repository exists with the command:

curl -XGET "http://localhost:9200/_snapshot/testing_repo" -H "kbn-xsrf: reporting"

Resulting output:

{
"testing_repo": {
"type": "gcs",
"settings": {
"bucket": "u37516e6a2fb2494499cbb13996a5f",
"client": "elastic-internal-93bb98",
"base_path": "snapshots/testing",
"compress": "true"
}
}
}

Elasticsearch Verify Repository

The following example shows how to use the verify snapshot repository API:

curl -XPOST "http://localhost:9200/_snapshot/testing_repo/_verify" -H "kbn-xsrf: reporting"

The query should return the response body as shown:

{
"nodes": {
"-kEiC1f_SQ2uAcSGrtdzgw": {
"name": "instance-0000000000"
},
"-Als2cLMSCqnWZaLYFLmRA": {
"name": "instance-0000000001"
}
}
}

Conclusion

This tutorial shows how to use the verify snapshot repository API. Feel free to explore the document to learn more.

Thanks for reading!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list