Before proceeding with the following steps, connect to the target machine or use the machine’s external IP address (if you have the necessary permissions).
Step 1: Get All Items in Elasticsearch
List all Indexes in Elasticsearch:
curl -u "user:password" -X GET "localhost:9200/_cat/indices?v"
List all items in the specific Index:
curl -u "user:password" -X GET "localhost:9200/products/_search?pretty"
Step 2: Create a Snapshot
Create a snapshot of your Elasticsearch data:
time curl -u "user:password" -X PUT "http://localhost:9200/_snapshot/test-elasticsearch-space/snapshot_$(date +%Y%m%d%H%M%S)?wait_for_completion=true&pretty" -H 'Content-Type: application/json' -d'
{
"indices": "*",
"ignore_unavailable": true,
"include_global_state": true
}
'
where:
-
http://127.0.0.1:9200: The Elasticsearch endpoint. -
/_snapshot/test-elasticsearch-space: Specifies the registered snapshot repository (test-elasticsearch-space). -
/snapshot_$(date +%Y%m%d%H%M%S): Dynamically generates a unique snapshot name using the current date and time in the formatYYYYMMDDHHMMSS. This ensures that snapshots have unique names. -
?wait_for_completion=true: Ensures the operation waits until the snapshot creation is complete before returning a response. -
&pretty: Formats the JSON response for better readability.
Verifying Snapshots
List All Available Snapshots
curl -u "user:password" -X GET "http://localhost:9200/_cat/snapshots/test-elasticsearch-space?v&s=id&pretty"
Verify all snapshots stored in the repository (for detailed inspection and debugging):
curl -u "user:password" -X GET "http://localhost:9200/_snapshot/test-elasticsearch-space/_all?pretty"
To retrieve detailed information about a specific snapshot:
curl -u "user:password" -X GET "http://localhost:9200/_snapshot/test-elasticsearch-space/snapshot_20241211144811?pretty"
Verifying Elasticsearch Data in DigitalOcean Spaces
-
From the left-hand menu, click Spaces Object Storage under the Manage section.
-
Select the Space where ElasticSearch snapshots are stored
-
In the Space, open the directory configured as the
base_pathin Elasticsearch
-
Inside the
base_pathdirectory, look for snapshot files. These may include:
-
metadata-*.datfiles: Metadata for the snapshots. -
snapshot-*.datfiles: The actual snapshot data. -
index-*files: Index-specific metadata.
Deleting a Snapshot
curl -u "user:password" -X DELETE "http://localhost:9200/_snapshot/test-elasticsearch-space/snapshot_20241211144811?pretty"

Leave a Reply
You must be logged in to post a comment.