mirror of https://github.com/digint/btrbk
btrbk: fixed mapping of subvoume cmdline args
parent
f9f85b5cb0
commit
a96bb4209f
46
btrbk
46
btrbk
|
@ -1330,9 +1330,9 @@ sub print_header(@) {
|
||||||
}
|
}
|
||||||
if($config) {
|
if($config) {
|
||||||
print " Config: $config->{SRC_FILE}\n";
|
print " Config: $config->{SRC_FILE}\n";
|
||||||
if($config->{RUN_FILTER}) {
|
if($config->{CMDLINE_FILTER}) {
|
||||||
print " Filter: ";
|
print " Filter: ";
|
||||||
print join("\n ", map { $_->{PRINT} } @{$config->{RUN_FILTER}});
|
print join("\n ", map { $_->{PRINT} } @{$config->{CMDLINE_FILTER}});
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,39 +1618,41 @@ MAIN:
|
||||||
if(($action_run || $action_tree) && scalar(@subvol_args))
|
if(($action_run || $action_tree) && scalar(@subvol_args))
|
||||||
{
|
{
|
||||||
my $filter_count = undef;
|
my $filter_count = undef;
|
||||||
$config->{RUN_FILTER} = [];
|
my @filter;
|
||||||
foreach my $config_vol (@{$config->{VOLUME}})
|
my %match;
|
||||||
{
|
foreach my $config_vol (@{$config->{VOLUME}}) {
|
||||||
my $vol_url = $config_vol->{url} // die;
|
my $vol_url = $config_vol->{url} // die;
|
||||||
if(grep(/^\Q$vol_url\E$/, @subvol_args)) {
|
if(grep(/^\Q$vol_url\E$/, @subvol_args)) {
|
||||||
$filter_count++;
|
push(@filter, vinfo($vol_url, $config_vol));
|
||||||
push(@{$config->{RUN_FILTER}}, vinfo($vol_url, $config_vol));
|
$match{$vol_url} = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
my @filter_subvol;
|
||||||
my $subvol_filter_count = 0;
|
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) {
|
||||||
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
|
my $subvol_url = $config_subvol->{url} // die;
|
||||||
{
|
if(grep(/^\Q$subvol_url\E$/, @subvol_args)) {
|
||||||
my $svol_url = $config_subvol->{url} // die;
|
push(@filter_subvol, vinfo($subvol_url, $config_subvol));
|
||||||
if(grep(/^\Q$svol_url\E$/, @subvol_args)) {
|
$match{$subvol_url} = 1;
|
||||||
$subvol_filter_count++;
|
} else {
|
||||||
push(@{$config->{RUN_FILTER}}, vinfo($svol_url, $config_subvol));
|
DEBUG "No match on subvolume command line argument, skipping subvolume: $subvol_url";
|
||||||
}
|
|
||||||
else {
|
|
||||||
DEBUG "No match on subvolume command line argument, skipping subvolume: $svol_url";
|
|
||||||
$config_subvol->{ABORTED} = "USER_SKIP";
|
$config_subvol->{ABORTED} = "USER_SKIP";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($subvol_filter_count == 0) {
|
unless(@filter_subvol) {
|
||||||
DEBUG "No match on subvolume command line argument, skipping volume: $vol_url";
|
DEBUG "No match on subvolume command line argument, skipping volume: $vol_url";
|
||||||
$config_vol->{ABORTED} = "USER_SKIP";
|
$config_vol->{ABORTED} = "USER_SKIP";
|
||||||
}
|
}
|
||||||
$filter_count += $subvol_filter_count;
|
push(@filter, @filter_subvol);
|
||||||
}
|
}
|
||||||
if($filter_count == 0) {
|
# make sure all args have a match
|
||||||
ERROR "Subvolume command line arguments do not match any volume/subvolume declaration from configuration file, aborting.";
|
my @nomatch = map { $match{$_} ? () : $_ } @subvol_args;
|
||||||
|
if(@nomatch) {
|
||||||
|
foreach(@nomatch) {
|
||||||
|
ERROR "Command line argument does not match any volume/subvolume declaration: $_";
|
||||||
|
}
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
$config->{CMDLINE_FILTER} = \@filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue