From 6510b5af15d9ce895211e04a7215e245a49985cd Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 8 Sep 2021 12:31:33 +0700 Subject: [PATCH] autobackup before making any changes, fixing number_of_replicas datatype --- tubearchivist/home/src/index_management.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tubearchivist/home/src/index_management.py b/tubearchivist/home/src/index_management.py index e1837b9..819ecce 100644 --- a/tubearchivist/home/src/index_management.py +++ b/tubearchivist/home/src/index_management.py @@ -64,7 +64,7 @@ INDEX_CONFIG = [ } } }, - "number_of_replicas": 0 + "number_of_replicas": "0" } }, { @@ -155,7 +155,7 @@ INDEX_CONFIG = [ } } }, - "number_of_replicas": 0 + "number_of_replicas": "0" } }, { @@ -206,7 +206,7 @@ INDEX_CONFIG = [ } } }, - "number_of_replicas": 0 + "number_of_replicas": "0" } } ] @@ -489,6 +489,9 @@ def restore_from_backup(): def index_check(force_restore=False): """ check if all indexes are created and have correct mapping """ + + backed_up = False + for index in INDEX_CONFIG: index_name = index['index_name'] expected_map = index['expected_map'] @@ -509,6 +512,12 @@ def index_check(force_restore=False): # validate index rebuild = handler.validate() if rebuild: + # make backup before rebuild + if not backed_up: + print('running backup first') + backup_all_indexes() + backed_up = True + print(f'applying new mappings to index ta_{index_name}...') handler.rebuild_index() continue