mirror of https://github.com/digint/btrbk
btrbk: allow filtering by "<target-directory>/<snapshot-name>", which makes it possible to pinpoint a single target
parent
8059fa28db
commit
b3d8c1f15f
13
btrbk
13
btrbk
|
@ -69,7 +69,7 @@ my %config_options = (
|
||||||
# NOTE: the parser always maps "no" to undef
|
# NOTE: the parser always maps "no" to undef
|
||||||
# NOTE: keys "volume", "subvolume" and "target" are hardcoded
|
# NOTE: keys "volume", "subvolume" and "target" are hardcoded
|
||||||
snapshot_dir => { default => undef, accept_file => { relative => 1 } },
|
snapshot_dir => { default => undef, accept_file => { relative => 1 } },
|
||||||
snapshot_name => { default => undef, accept_file => { name_only => 1 }, context => [ "subvolume" ] },
|
snapshot_name => { default => undef, accept_file => { name_only => 1 }, context => [ "subvolume" ] }, # NOTE: defaults to the subvolume name (hardcoded)
|
||||||
snapshot_create => { default => "always", accept => [ "no", "always", "ondemand", "onchange" ] },
|
snapshot_create => { default => "always", accept => [ "no", "always", "ondemand", "onchange" ] },
|
||||||
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
|
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
|
||||||
resume_missing => { default => "yes", accept => [ "yes", "no" ] },
|
resume_missing => { default => "yes", accept => [ "yes", "no" ] },
|
||||||
|
@ -496,10 +496,13 @@ sub parse_config(@)
|
||||||
$value =~ s/^\/+//; # remove leading slash
|
$value =~ s/^\/+//; # remove leading slash
|
||||||
|
|
||||||
TRACE "config: adding subvolume \"$value\" to volume context: $cur->{url}";
|
TRACE "config: adding subvolume \"$value\" to volume context: $cur->{url}";
|
||||||
|
my $snapshot_name = $value;
|
||||||
|
$snapshot_name =~ s/^.*\///; # snapshot_name defaults to subvolume name
|
||||||
my $subvolume = { CONTEXT => "subvolume",
|
my $subvolume = { CONTEXT => "subvolume",
|
||||||
PARENT => $cur,
|
PARENT => $cur,
|
||||||
rel_path => $value,
|
rel_path => $value,
|
||||||
url => $cur->{url} . '/' . $value,
|
url => $cur->{url} . '/' . $value,
|
||||||
|
snapshot_name => $snapshot_name,
|
||||||
};
|
};
|
||||||
$cur->{SUBVOLUME} //= [];
|
$cur->{SUBVOLUME} //= [];
|
||||||
push(@{$cur->{SUBVOLUME}}, $subvolume);
|
push(@{$cur->{SUBVOLUME}}, $subvolume);
|
||||||
|
@ -1739,11 +1742,14 @@ MAIN:
|
||||||
}
|
}
|
||||||
next if($found_subvol);
|
next if($found_subvol);
|
||||||
|
|
||||||
|
my $snapshot_name = $config_subvol->{snapshot_name} // die;
|
||||||
foreach my $config_target (@{$config_subvol->{TARGET}}) {
|
foreach my $config_target (@{$config_subvol->{TARGET}}) {
|
||||||
my $target_url = $config_target->{url} // die;
|
my $target_url = $config_target->{url} // die;
|
||||||
my $found_target = 0;
|
my $found_target = 0;
|
||||||
foreach my $filter (@filter_args) {
|
foreach my $filter (@filter_args) {
|
||||||
if(($target_url eq $filter) || (map { ($filter eq $_) || () } @{$config_target->{group}})) {
|
if(($filter eq $target_url) ||
|
||||||
|
($filter eq "$target_url/$snapshot_name") ||
|
||||||
|
(map { ($filter eq $_) || () } @{$config_target->{group}})) {
|
||||||
TRACE "filter argument \"$filter\" matches target: $target_url\n";
|
TRACE "filter argument \"$filter\" matches target: $target_url\n";
|
||||||
$match{$filter} = ($target_url eq $filter) ? "target=" . vinfo($target_url, $config_target)->{PRINT} : "group=$filter";
|
$match{$filter} = ($target_url eq $filter) ? "target=" . vinfo($target_url, $config_target)->{PRINT} : "group=$filter";
|
||||||
$found_target = 1;
|
$found_target = 1;
|
||||||
|
@ -1878,9 +1884,6 @@ MAIN:
|
||||||
}
|
}
|
||||||
$config_subvol->{svol} = $svol;
|
$config_subvol->{svol} = $svol;
|
||||||
|
|
||||||
# set default for snapshot_name
|
|
||||||
$config_subvol->{snapshot_name} //= $svol->{NAME};
|
|
||||||
|
|
||||||
# check for duplicate snapshot locations
|
# check for duplicate snapshot locations
|
||||||
my $snapdir = config_key($config_subvol, "snapshot_dir", postfix => '/') // "";
|
my $snapdir = config_key($config_subvol, "snapshot_dir", postfix => '/') // "";
|
||||||
my $snapshot_basename = config_key($config_subvol, "snapshot_name") // die;
|
my $snapshot_basename = config_key($config_subvol, "snapshot_name") // die;
|
||||||
|
|
|
@ -198,7 +198,13 @@ configuration section.
|
||||||
.PP
|
.PP
|
||||||
[hostname:]<target-directory>
|
[hostname:]<target-directory>
|
||||||
.RS 4
|
.RS 4
|
||||||
Matches a single target of a \fItarget\fR configuration section.
|
Matches all targets of a \fItarget\fR configuration section.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
[hostname:]<target-directory>/<snapshot-name>
|
||||||
|
.RS 4
|
||||||
|
Matches a single target of a \fItarget\fR section within a
|
||||||
|
\fIsubvolume\fR section with given <snapshot-name>.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
<group-name>
|
<group-name>
|
||||||
|
|
|
@ -70,7 +70,8 @@ will fail if it is not present.
|
||||||
\fBsnapshot_name\fR <basename>
|
\fBsnapshot_name\fR <basename>
|
||||||
.RS 4
|
.RS 4
|
||||||
Base name of the created snapshot (and backup). This option is only
|
Base name of the created snapshot (and backup). This option is only
|
||||||
valid in the \fItarget\fR section. Defaults to \fI<subvolume-name>\fR.
|
valid in the \fIsubvolume\fR section. Defaults to
|
||||||
|
\fI<subvolume-name>\fR.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBsnapshot_create\fR always|ondemand|onchange|no
|
\fBsnapshot_create\fR always|ondemand|onchange|no
|
||||||
|
|
Loading…
Reference in New Issue