From b7dcb17fd50843a51ef6cfeaf0310f22b2688f9a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 11 Jan 2024 20:51:55 +0100 Subject: [PATCH] Optimized logic for central databases --- backup-docker-to-local.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backup-docker-to-local.py b/backup-docker-to-local.py index 2b03b7d..0db8177 100644 --- a/backup-docker-to-local.py +++ b/backup-docker-to-local.py @@ -71,11 +71,10 @@ def get_instance(container): # This line uses regular expressions to split the 'container' string. # 're.split' is a method that divides a string into a list, based on the occurrences of a pattern. - instance_name_elements = re.split("(_|-)(database|db|postgres)", container) - if instance_name_elements[0] == 'central': - instance_name = f"{instance_name_elements[0]}-{instance_name_elements[1]}" + if container in ['central-mariadb', 'central-postgres']: + instance_name = container else: - instance_name = instance_name_elements[0] + instance_name = re.split("(_|-)(database|db|postgres)", container)[0] # The pattern "(_|-)(database|db|postgres)" is explained as follows: # - "(_|-)": Matches an underscore '_' or a hyphen '-'.