diff --git a/src/restic_compose_backup/cli.py b/src/restic_compose_backup/cli.py index 08dc3fc..f976b6a 100644 --- a/src/restic_compose_backup/cli.py +++ b/src/restic_compose_backup/cli.py @@ -113,7 +113,7 @@ def backup(config, containers): environment=containers.this_container.environment, source_container_id=containers.this_container.id, labels={ - "restic-compose-backup.backup_process": 'True', + containers.backup_process_label: 'True', "com.docker.compose.project": containers.project_name, }, ) diff --git a/src/restic_compose_backup/containers.py b/src/restic_compose_backup/containers.py index 9eabb90..549bf19 100644 --- a/src/restic_compose_backup/containers.py +++ b/src/restic_compose_backup/containers.py @@ -141,7 +141,7 @@ class Container: @property def is_backup_process_container(self) -> bool: """Is this container the running backup process?""" - return self.get_label(enums.LABEL_BACKUP_PROCESS) == 'True' + return self.get_label(self.backup_process_label) == 'True' @property def is_running(self) -> bool: @@ -158,6 +158,11 @@ class Container: """Name of the container/service""" return self.get_label('com.docker.compose.service', default='') + @property + def backup_process_label(self) -> str: + """str: The unique backup process label for this project""" + return f"{enums.LABEL_BACKUP_PROCESS}-{self.project_name}" + @property def project_name(self) -> str: """Name of the compose setup""" @@ -358,6 +363,11 @@ class RunningContainers: """str: Name of the compose project""" return self.this_container.project_name + @property + def backup_process_label(self) -> str: + """str: The backup process label for this project""" + return self.this_container.backup_process_label + @property def backup_process_running(self) -> bool: """Is the backup process container running?""" diff --git a/src/restic_compose_backup/enums.py b/src/restic_compose_backup/enums.py index e8261be..ac557d0 100644 --- a/src/restic_compose_backup/enums.py +++ b/src/restic_compose_backup/enums.py @@ -8,4 +8,4 @@ LABEL_MYSQL_ENABLED = 'restic-compose-backup.mysql' LABEL_POSTGRES_ENABLED = 'restic-compose-backup.postgres' LABEL_MARIADB_ENABLED = 'restic-compose-backup.mariadb' -LABEL_BACKUP_PROCESS = 'restic-compose-backup.backup_process' +LABEL_BACKUP_PROCESS = 'restic-compose-backup.process'