Exclude / include info

This commit is contained in:
Einar Forselv 2019-04-14 01:34:39 +02:00
parent 5287f7be8e
commit 3e0861c85e
1 changed files with 18 additions and 7 deletions

View File

@ -12,10 +12,13 @@ class Container:
def __init__(self, data):
self.id = data.get('Id')
self.state = data.get('State')
self.labels = data.get('Labels')
self.names = data.get('Names')
self.labels = data.get('Labels', {})
self.names = data.get('Names', [])
self.mounts = [Mount(mnt, container=self) for mnt in data.get('Mounts')]
self.include = self.labels.get('restic-volume-backup.enabled', '').split(',')
self.exlude = self.labels.get('restic-volume-backup.exclude', '').split(',')
@property
def backup_enabled(self):
return self.labels.get('restic-volume-backup.enabled') == 'True'
@ -133,12 +136,20 @@ class RunningContainers:
for container in self.all_containers:
# Weed out containers not beloging to this project.
if container.project_name == self.backup_container.project_name:
if container.project_name != self.backup_container.project_name:
continue
# Keep only containers with backup enabled
if not container.backup_enabled:
container
# and not oneoffs (started manually with run or similar)
if container.backup_enabled and not container.is_oneoff:
if container.is_oneoff:
continue
self.containers.append(container)
def backup_volumes(self):
return self.backup_container.mounts