I'm using python to access elasticsearch cluster. Now I want to backup my index by using snapshot. The most difficult thing is that: the python-elasticsearch's doc just give me a API description. there is no example to show me how to create snapshot. I tried some parameters, but failed. Can anyone give a snapshot example of elastic-search by using python? The following is my code:
from elasticsearch import Elasticsearch
es = Elasticsearch()
snapshot_body = {
"type": "url",
"settings": {
"url": "http://download.elasticsearch.org/definitiveguide/sigterms_demo/"
}
}
body = {"snapshot": snapshot_body}
es.snapshot.create_repository(repository='test', body=body)
Your repository creation is almost correct, you don't need the line
body = {"snapshot": snapshot_body}
, simply create your repository like this:Now in order to create a snapshot, all you have to do is this:
If you want to store only a few indices and not all you can also provide a body like this: