From dcc57abac41d7ae8e13cbceec4397be093b9c5a8 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sun, 4 Aug 2019 21:37:17 +0200 Subject: [PATCH] btrbk: archive: also apply exclude patterns on source subvolumes Allows patterns like "svol.2019*". Needs @exclude_vf to be a global variable, which is ok as this only holds command-line args (and global context for archive_exclude). Note that adding the same in "create backups" (action run) and macro_delete() is not a good idea, as this has weird implications on the "forced: last" snapshot/backup pair. --- btrbk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/btrbk b/btrbk index 7570b2a..640d4ec 100755 --- a/btrbk +++ b/btrbk @@ -280,6 +280,7 @@ my $fake_uuid_prefix = 'XXXXXXXX-XXXX-XXXX-XXXX-'; # plus 0-padded inject_id: XX my $dryrun; my $loglevel = 1; my $quiet; +my @exclude_vf; my $do_dumper; my $show_progress = 0; my $err = ""; @@ -4191,6 +4192,10 @@ sub macro_archive_target($$$;$) foreach my $svol (@{vinfo_subvol_list($sroot, readonly => 1, btrbk_direct_leaf => $snapshot_name, sort => 'path')}) { next if(get_receive_targets($droot, $svol, exact => 1, warn => 1, ret_unexpected => \$has_unexpected_location)); + if(my $ff = vinfo_match(\@exclude_vf, $svol)) { + INFO "Skipping archive candidate \"$svol->{PRINT}\": Match on exclude pattern \"$ff->{unparsed}\""; + next; + } DEBUG "Adding archive candidate: $svol->{PRINT}"; push @schedule, { value => $svol, @@ -5092,7 +5097,6 @@ MAIN: } push @filter_vf, $vf; } - my @exclude_vf; foreach (@exclude_cmdline) { my $vf = vinfo_filter_statement($_); unless($vf) { @@ -5444,7 +5448,7 @@ MAIN: if(vinfo_match(\@exclude_vf, $sroot) || vinfo_match(\@exclude_vf, vinfo_child($sroot, $snapshot_name))) { - ABORTED($sroot, "skip_archive_exclude", "Match on archive_exclude"); + ABORTED($sroot, "skip_archive_exclude", "Match on exclude pattern"); INFO "Skipping archive subvolumes \"$sroot->{PRINT}/${snapshot_name}.*\": " . ABORTED_TEXT($sroot); next; }