From 3e0861c85e6bb63945d0ce05f92825acdf89c1f7 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Sun, 14 Apr 2019 01:34:39 +0200
Subject: [PATCH] Exclude / include info

---
 restic-backup/containers.py | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/restic-backup/containers.py b/restic-backup/containers.py
index 9603522..5f18964 100644
--- a/restic-backup/containers.py
+++ b/restic-backup/containers.py
@@ -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,11 +136,19 @@ 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:
-                # Keep only containers with backup enabled
-                # and not oneoffs (started manually with run or similar)
-                if container.backup_enabled and not container.is_oneoff:
-                    self.containers.append(container)
+            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.is_oneoff:
+                continue
+
+            self.containers.append(container)
+
 
     def backup_volumes(self):
         return self.backup_container.mounts