handle aliased snapshot restore

This commit is contained in:
Simon 2026-01-24 17:39:36 +07:00
parent 5e018f1224
commit 229113a1ed
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 7 additions and 2 deletions

View File

@ -261,10 +261,15 @@ class ElasticSnapshot:
def restore_all(self, snapshot_name):
"""restore snapshot by name"""
for index in self.all_indices:
_, _ = ElasticWrap(index).delete()
response, status_code = ElasticWrap(index).get()
if status_code == 404:
continue
index_alias = list(response.keys())[0]
_, _ = ElasticWrap(index_alias).delete()
path = f"_snapshot/{self.REPO}/{snapshot_name}/_restore"
data = {"indices": "*"}
data = {"indices": "*,-.*"}
response, statuscode = ElasticWrap(path).post(data=data)
if statuscode == 200:
print(f"snapshot: executing now: {response}")