mirror of https://github.com/digint/btrbk
btrbk: allow "{snapshot,target}_preserve no": disable retention policy
parent
a03c515b0a
commit
a1ee9d5c6d
47
btrbk
47
btrbk
|
@ -79,9 +79,9 @@ my %config_options = (
|
||||||
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" ] },
|
||||||
preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] },
|
preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] },
|
||||||
snapshot_preserve => { default => undef, accept_preserve_matrix => 1, context => [ "root", "volume", "subvolume" ], },
|
snapshot_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1, context => [ "root", "volume", "subvolume" ], },
|
||||||
snapshot_preserve_min => { default => "1d", accept => [ "all", "latest" ], accept_regexp => qr/^[1-9][0-9]*[hdwmy]$/, context => [ "root", "volume", "subvolume" ], },
|
snapshot_preserve_min => { default => "1d", accept => [ "all", "latest" ], accept_regexp => qr/^[1-9][0-9]*[hdwmy]$/, context => [ "root", "volume", "subvolume" ], },
|
||||||
target_preserve => { default => undef, accept_preserve_matrix => 1 },
|
target_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1 },
|
||||||
target_preserve_min => { default => undef, accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ },
|
target_preserve_min => { default => undef, accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ },
|
||||||
btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] },
|
btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] },
|
||||||
ssh_identity => { default => undef, accept_file => { absolute => 1 } },
|
ssh_identity => { default => undef, accept_file => { absolute => 1 } },
|
||||||
|
@ -2179,28 +2179,6 @@ sub append_config_option($$$$;$)
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($opt->{accept_preserve_matrix}) {
|
|
||||||
my %preserve;
|
|
||||||
my $s = ' ' . $value;
|
|
||||||
while($s =~ s/\s+(\*|[0-9]+)([hdwmyHDWMY])//) {
|
|
||||||
my $n = $1;
|
|
||||||
my $q = lc($2); # qw( h d w m y )
|
|
||||||
$n = 'all' if($n eq '*');
|
|
||||||
if(exists($preserve{$q})) {
|
|
||||||
ERROR "Value \"$value\" failed input validation for option \"$key\": multiple definitions of '$q'" . $config_file_statement;
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
$preserve{$q} = $n;
|
|
||||||
}
|
|
||||||
unless($s eq "") {
|
|
||||||
ERROR "Value \"$value\" failed input validation for option \"$key\"" . $config_file_statement;
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
TRACE "adding preserve matrix $context context:" . Data::Dumper->new([\%preserve], [ $key ])->Indent(0)->Pad(' ')->Quotekeys(0)->Pair('=>')->Dump() if($loglevel >= 4);
|
|
||||||
$config->{$key} = \%preserve;
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(grep(/^\Q$value\E$/, @{$opt->{accept}})) {
|
if(grep(/^\Q$value\E$/, @{$opt->{accept}})) {
|
||||||
TRACE "option \"$key=$value\" found in accept list";
|
TRACE "option \"$key=$value\" found in accept list";
|
||||||
}
|
}
|
||||||
|
@ -2227,6 +2205,27 @@ sub append_config_option($$$$;$)
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif($opt->{accept_preserve_matrix}) {
|
||||||
|
my %preserve;
|
||||||
|
my $s = ' ' . $value;
|
||||||
|
while($s =~ s/\s+(\*|[0-9]+)([hdwmyHDWMY])//) {
|
||||||
|
my $n = $1;
|
||||||
|
my $q = lc($2); # qw( h d w m y )
|
||||||
|
$n = 'all' if($n eq '*');
|
||||||
|
if(exists($preserve{$q})) {
|
||||||
|
ERROR "Value \"$value\" failed input validation for option \"$key\": multiple definitions of '$q'" . $config_file_statement;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
$preserve{$q} = $n;
|
||||||
|
}
|
||||||
|
unless($s eq "") {
|
||||||
|
ERROR "Value \"$value\" failed input validation for option \"$key\"" . $config_file_statement;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
TRACE "adding preserve matrix $context context:" . Data::Dumper->new([\%preserve], [ $key ])->Indent(0)->Pad(' ')->Quotekeys(0)->Pair('=>')->Dump() if($loglevel >= 4);
|
||||||
|
$config->{$key} = \%preserve;
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR "Unsupported value \"$value\" for option \"$key\"" . $config_file_statement;
|
ERROR "Unsupported value \"$value\" for option \"$key\"" . $config_file_statement;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH "btrbk" "1" "2016-04-11" "btrbk v0.23.0-dev" ""
|
.TH "btrbk" "1" "2016-04-14" "btrbk v0.23.0-dev" ""
|
||||||
.\" disable hyphenation
|
.\" disable hyphenation
|
||||||
.nh
|
.nh
|
||||||
.\" disable justification (adjust text to left margin only)
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
@ -144,6 +144,10 @@ retention policy will be deleted. Note that the latest snapshot (the
|
||||||
one created in the first step) as well as the latest snapshot/backup
|
one created in the first step) as well as the latest snapshot/backup
|
||||||
pair are always preserved, regardless of the retention policy.
|
pair are always preserved, regardless of the retention policy.
|
||||||
.PP
|
.PP
|
||||||
|
See section RETENTION POLICY in
|
||||||
|
.BR btrbk.conf (5)
|
||||||
|
for information on configuring the retention policy.
|
||||||
|
.PP
|
||||||
Use the \fI\-\-format\fR command line option to switch between
|
Use the \fI\-\-format\fR command line option to switch between
|
||||||
different output formats.
|
different output formats.
|
||||||
.RE
|
.RE
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH "btrbk.conf" "5" "2016-04-12" "btrbk v0.23.0-dev" ""
|
.TH "btrbk.conf" "5" "2016-04-14" "btrbk v0.23.0-dev" ""
|
||||||
.\" disable hyphenation
|
.\" disable hyphenation
|
||||||
.nh
|
.nh
|
||||||
.\" disable justification (adjust text to left margin only)
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
@ -121,9 +121,11 @@ non-incremental (initial) backups are never created. Defaults to
|
||||||
\[lq]yes\[rq].
|
\[lq]yes\[rq].
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBsnapshot_preserve\fR <retention_policy>
|
\fBsnapshot_preserve\fR no|<retention_policy>
|
||||||
.RS 4
|
.RS 4
|
||||||
Set retention policy for snapshots (see RETENTION POLICY below).
|
Set retention policy for snapshots (see RETENTION POLICY below). If
|
||||||
|
set to \[lq]no\[rq], preserve snapshots according to
|
||||||
|
\fIsnapshot_preserve_min\fR only. Defaults to \[lq]no\[rq].
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBsnapshot_preserve_min\fR all|latest|<number>{h,d,w,m,y}
|
\fBsnapshot_preserve_min\fR all|latest|<number>{h,d,w,m,y}
|
||||||
|
@ -135,9 +137,11 @@ to \[lq]latest\[rq], preserve latest snapshot. Defaults to
|
||||||
\[lq]1d\[rq].
|
\[lq]1d\[rq].
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBtarget_preserve\fR <retention_policy>
|
\fBtarget_preserve\fR no|<retention_policy>
|
||||||
.RS 4
|
.RS 4
|
||||||
Set retention policy for backups (see RETENTION POLICY below).
|
Set retention policy for backups (see RETENTION POLICY below). If set
|
||||||
|
to \[lq]no\[rq], preserve backups according to
|
||||||
|
\fItarget_preserve_min\fR only. Defaults to \[lq]no\[rq].
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBtarget_preserve_min\fR all|latest|no|<number>{h,d,w,m,y}
|
\fBtarget_preserve_min\fR all|latest|no|<number>{h,d,w,m,y}
|
||||||
|
|
Loading…
Reference in New Issue