mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-30 05:13:01 +02:00
Strip comments from patterns (#962).
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user