Only obtain containers with backup enabled
This commit is contained in:
parent
01f7cef709
commit
ba642eeb4b
|
@ -34,11 +34,16 @@ def status(config, containers):
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
for container in containers.containers:
|
backup_containers = containers.containers_for_backup()
|
||||||
|
for container in backup_containers:
|
||||||
|
if container.backup_enabled:
|
||||||
print('service: {}'.format(container.service_name))
|
print('service: {}'.format(container.service_name))
|
||||||
for mount in container.filter_mounts():
|
for mount in container.filter_mounts():
|
||||||
print(' - {}'.format(mount.source))
|
print(' - {}'.format(mount.source))
|
||||||
|
|
||||||
|
if len(backup_containers) == 0:
|
||||||
|
print("No containers in the project has 'restic-volume-backup.enabled' label")
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Container:
|
||||||
@property
|
@property
|
||||||
def backup_enabled(self) -> bool:
|
def backup_enabled(self) -> bool:
|
||||||
"""Is backup enabled for this container?"""
|
"""Is backup enabled for this container?"""
|
||||||
return self.get_label('restic-volume-backup.enabled') == 'True'
|
return self.get_label('restic-volume-backup.enabled') is not None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_backup_process_container(self) -> bool:
|
def is_backup_process_container(self) -> bool:
|
||||||
|
@ -225,6 +225,10 @@ class RunningContainers:
|
||||||
"""Is the backup process container running?"""
|
"""Is the backup process container running?"""
|
||||||
return self.backup_process_container is not None
|
return self.backup_process_container is not None
|
||||||
|
|
||||||
|
def containers_for_backup(self):
|
||||||
|
"""Obtain all containers with backup enabled"""
|
||||||
|
return [container for container in self.containers if container.backup_enabled]
|
||||||
|
|
||||||
def get_service(self, name) -> Container:
|
def get_service(self, name) -> Container:
|
||||||
for container in self.containers:
|
for container in self.containers:
|
||||||
if container.service_name == name:
|
if container.service_name == name:
|
||||||
|
|
Loading…
Reference in New Issue