diff --git a/borgmatic/actions/create.py b/borgmatic/actions/create.py index 4fdd60ef..8075b34d 100644 --- a/borgmatic/actions/create.py +++ b/borgmatic/actions/create.py @@ -50,7 +50,11 @@ def collect_patterns(config): borgmatic.borg.pattern.Pattern(source_directory) for source_directory in config.get('source_directories', ()) ) - + tuple(parse_pattern(pattern_line) for pattern_line in config.get('patterns', ())) + + tuple( + parse_pattern(pattern_line) + for pattern_line in config.get('patterns', ()) + if not pattern_line.lstrip().startswith('#') + ) + tuple( borgmatic.borg.pattern.Pattern( exclude_line, @@ -64,6 +68,7 @@ def collect_patterns(config): parse_pattern(pattern_line) for filename in config.get('patterns_from', ()) for pattern_line in open(filename).readlines() + if not pattern_line.lstrip().startswith('#') ) ) + tuple( diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 39760145..29d23f16 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -215,7 +215,9 @@ def make_base_create_command( if config.get('source_directories_must_exist', False): check_all_root_patterns_exist(patterns) - patterns_file = write_patterns_file(patterns, borgmatic_runtime_directory, log_prefix=repository_path) + patterns_file = write_patterns_file( + patterns, borgmatic_runtime_directory, log_prefix=repository_path + ) checkpoint_interval = config.get('checkpoint_interval', None) checkpoint_volume = config.get('checkpoint_volume', None) chunker_params = config.get('chunker_params', None) diff --git a/borgmatic/hooks/data_source/btrfs.py b/borgmatic/hooks/data_source/btrfs.py index 2ad7590a..fc135e4d 100644 --- a/borgmatic/hooks/data_source/btrfs.py +++ b/borgmatic/hooks/data_source/btrfs.py @@ -73,9 +73,7 @@ def get_subvolumes_for_filesystem(btrfs_command, filesystem_mount_point): ) -Subvolume = collections.namedtuple( - 'Subvolume', ('path', 'contained_patterns'), defaults=((),) -) +Subvolume = collections.namedtuple('Subvolume', ('path', 'contained_patterns'), defaults=((),)) def get_subvolumes(btrfs_command, findmnt_command, patterns=None): @@ -256,7 +254,9 @@ def dump_data_sources( for pattern in subvolume.contained_patterns: # Update the pattern in place, since pattern order matters to Borg. try: - patterns[patterns.index(pattern)] = make_borg_snapshot_pattern(subvolume.path, pattern) + patterns[patterns.index(pattern)] = make_borg_snapshot_pattern( + subvolume.path, pattern + ) except ValueError: pass diff --git a/borgmatic/hooks/data_source/lvm.py b/borgmatic/hooks/data_source/lvm.py index d4deffbb..0584e3a2 100644 --- a/borgmatic/hooks/data_source/lvm.py +++ b/borgmatic/hooks/data_source/lvm.py @@ -57,9 +57,7 @@ def get_logical_volumes(lsblk_command, patterns=None): try: return tuple( - Logical_volume( - device['name'], device['path'], device['mountpoint'], contained_patterns - ) + Logical_volume(device['name'], device['path'], device['mountpoint'], contained_patterns) for device in devices_info['blockdevices'] if device['mountpoint'] and device['type'] == 'lvm' for contained_patterns in ( @@ -232,11 +230,9 @@ def dump_data_sources( for pattern in logical_volume.contained_patterns: # Update the pattern in place, since pattern order matters to Borg. try: - patterns[patterns.index(pattern)] = ( - make_borg_snapshot_pattern( - pattern, - normalized_runtime_directory, - ) + patterns[patterns.index(pattern)] = make_borg_snapshot_pattern( + pattern, + normalized_runtime_directory, ) except ValueError: pass diff --git a/borgmatic/hooks/data_source/zfs.py b/borgmatic/hooks/data_source/zfs.py index d4c1f3b8..4524b1e1 100644 --- a/borgmatic/hooks/data_source/zfs.py +++ b/borgmatic/hooks/data_source/zfs.py @@ -252,11 +252,9 @@ def dump_data_sources( for pattern in dataset.contained_patterns: # Update the pattern in place, since pattern order matters to Borg. try: - patterns[patterns.index(pattern)] = ( - make_borg_snapshot_pattern( - pattern, - normalized_runtime_directory, - ) + patterns[patterns.index(pattern)] = make_borg_snapshot_pattern( + pattern, + normalized_runtime_directory, ) except ValueError: pass