From faa2d9ff7e77ea39a3bf57bc9187ee7e5b121331 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 4 Dec 2019 22:25:09 +0100 Subject: [PATCH] Do not filter mounts if volume backup is not enabled --- restic_compose_backup/containers.py | 6 +++++- tests/tests.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/restic_compose_backup/containers.py b/restic_compose_backup/containers.py index ee1d971..193c048 100644 --- a/restic_compose_backup/containers.py +++ b/restic_compose_backup/containers.py @@ -158,8 +158,12 @@ class Container: return self._labels.get(name, None) def filter_mounts(self): - """Get all mounts for this container matching include/exclude filters""" + """Get all mounts for this container matching include/exclude filters""" filtered = [] + + if not self.volume_backup_enabled: + return filtered + if self._include: for mount in self._mounts: for pattern in self._include: diff --git a/tests/tests.py b/tests/tests.py index 2cae34c..3614f92 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -59,6 +59,7 @@ class ResticBackupTests(unittest.TestCase): { 'service': 'web', 'labels': { + 'restic-compose-backup.volumes': True, 'test': 'test', }, 'mounts': [{ @@ -119,6 +120,7 @@ class ResticBackupTests(unittest.TestCase): { 'service': 'web', 'labels': { + 'restic-compose-backup.volumes': True, 'restic-compose-backup.volumes.include': 'media', }, 'mounts': [ @@ -152,6 +154,7 @@ class ResticBackupTests(unittest.TestCase): { 'service': 'web', 'labels': { + 'restic-compose-backup.volumes': True, 'restic-compose-backup.volumes.exclude': 'stuff', }, 'mounts': [