Skip to content
Advertisement

How to I use the elasticsearch python api to get an overview of all snapshots?

I’m using the elasticsearch python api to communicate with my elasticsearch database. How can I make a specific GET request to get an overview of all the snapshots that have been created?

The Kibana command for this would be: GET /_snapshot/my_backup/_all.

It seems the Elasticsearch.get() function is only suited to retrieve documents.

I would rather not use the Requests module.

The snapshot helper functions I found only have the option to get an overview of snapshots that are currently running.

from elasticsearch import Elasticsearch
es = Elasticsearch()
es.snapshot.get_repository('my_backup') # configuration information
es.snapshot.status('my_backup') # currently running snapshots

Advertisement

Answer

I finally realized you can use the _all keyword when needing all snapshots, in the following way:

all_snapshots = es.snapshot.get(repository = 'my_backup', snapshot = '_all')

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement