mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 01:01:03 +01:00
Optimized logic for central databases
This commit is contained in:
parent
7f6f5f6dc8
commit
b7dcb17fd5
@ -71,11 +71,10 @@ def get_instance(container):
|
|||||||
|
|
||||||
# This line uses regular expressions to split the 'container' string.
|
# 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.
|
# '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 container in ['central-mariadb', 'central-postgres']:
|
||||||
if instance_name_elements[0] == 'central':
|
instance_name = container
|
||||||
instance_name = f"{instance_name_elements[0]}-{instance_name_elements[1]}"
|
|
||||||
else:
|
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:
|
# The pattern "(_|-)(database|db|postgres)" is explained as follows:
|
||||||
# - "(_|-)": Matches an underscore '_' or a hyphen '-'.
|
# - "(_|-)": Matches an underscore '_' or a hyphen '-'.
|
||||||
|
Loading…
Reference in New Issue
Block a user