mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 09:11:04 +01:00
Added comment, to prevent thinking in future. PS: Thanks ChatGPT :-*
This commit is contained in:
parent
4388e09937
commit
e2e62c5835
@ -66,7 +66,22 @@ BACKUP_TIME = datetime.now().strftime("%Y%m%d%H%M%S")
|
|||||||
VERSION_DIR = create_version_directory()
|
VERSION_DIR = create_version_directory()
|
||||||
|
|
||||||
def get_instance(container):
|
def get_instance(container):
|
||||||
|
# The function is defined to take one parameter, 'container',
|
||||||
|
# which is expected to be a 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.
|
||||||
instance_name = re.split("(_|-)(database|db|postgres)", container)[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 '-'.
|
||||||
|
# - "(database|db|postgres)": Matches one of the strings "database", "db", or "postgres".
|
||||||
|
# So, this pattern will match segments like "_database", "-db", "_postgres", etc.
|
||||||
|
# For example, in "central-db", it matches "-db".
|
||||||
|
|
||||||
|
# After splitting, [0] is used to select the first element of the list resulting from the split.
|
||||||
|
# This element is the string portion before the matched pattern.
|
||||||
|
# For "central-db", the split results in ["central", "db"], and [0] selects "central".
|
||||||
|
|
||||||
print(f"Extracted instance name: {instance_name}")
|
print(f"Extracted instance name: {instance_name}")
|
||||||
return instance_name
|
return instance_name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user