mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-26 05:30:17 +00:00
skip backing up not yet existing index
This commit is contained in:
parent
e3de9a0184
commit
5d7a609285
@ -529,6 +529,15 @@ class ElasticBackup:
|
|||||||
self.post_bulk_restore(file_name)
|
self.post_bulk_restore(file_name)
|
||||||
os.remove(file_name)
|
os.remove(file_name)
|
||||||
|
|
||||||
|
def index_exists(self, index_name):
|
||||||
|
"""check if index already exists to skip"""
|
||||||
|
es_url = self.config["application"]["es_url"]
|
||||||
|
es_auth = self.config["application"]["es_auth"]
|
||||||
|
url = f"{es_url}/ta_{index_name}"
|
||||||
|
response = requests.get(url, auth=es_auth)
|
||||||
|
|
||||||
|
return response.ok
|
||||||
|
|
||||||
|
|
||||||
def backup_all_indexes():
|
def backup_all_indexes():
|
||||||
"""backup all es indexes to disk"""
|
"""backup all es indexes to disk"""
|
||||||
@ -536,6 +545,8 @@ def backup_all_indexes():
|
|||||||
|
|
||||||
for index in backup_handler.index_config:
|
for index in backup_handler.index_config:
|
||||||
index_name = index["index_name"]
|
index_name = index["index_name"]
|
||||||
|
if not backup_handler.index_exists(index_name):
|
||||||
|
continue
|
||||||
all_results = backup_handler.get_all_documents(index_name)
|
all_results = backup_handler.get_all_documents(index_name)
|
||||||
file_content = backup_handler.build_bulk(all_results)
|
file_content = backup_handler.build_bulk(all_results)
|
||||||
backup_handler.write_es_json(file_content, index_name)
|
backup_handler.write_es_json(file_content, index_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user