btrbk: remove resume_missing configuration option

pull/88/head
Axel Burri 2016-04-12 19:43:12 +02:00
parent 738178565c
commit 55b121c372
4 changed files with 84 additions and 99 deletions

View File

@ -262,7 +262,6 @@ to only fetch the snapshots.
snapshot_dir btrbk_snapshots snapshot_dir btrbk_snapshots
snapshot_preserve_all forever snapshot_preserve_all forever
snapshot_create no snapshot_create no
resume_missing yes
target_preserve 0d 10w *m target_preserve 0d 10w *m

31
btrbk
View File

@ -78,7 +78,6 @@ my %config_options = (
snapshot_name => { default => undef, accept_file => { name_only => 1 }, context => [ "subvolume" ], deny_glob_context => 1 }, # NOTE: defaults to the subvolume name (hardcoded) snapshot_name => { default => undef, accept_file => { name_only => 1 }, context => [ "subvolume" ], deny_glob_context => 1 }, # 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" ] },
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_preserve_matrix => 1, context => [ "root", "volume", "subvolume" ], },
snapshot_preserve_all => { default => '12h', accept => [ "forever", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/, context => [ "root", "volume", "subvolume" ], }, snapshot_preserve_all => { default => '12h', accept => [ "forever", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/, context => [ "root", "volume", "subvolume" ], },
@ -111,11 +110,17 @@ my %config_options = (
snapshot_preserve_monthly => { default => 'all', accept => [ "all" ], accept_numeric => 1, context => [ "root", "volume", "subvolume" ], snapshot_preserve_monthly => { default => 'all', accept => [ "all" ], accept_numeric => 1, context => [ "root", "volume", "subvolume" ],
deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "snapshot_preserve" and/or "snapshot_preserve_all"' } } }, deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "snapshot_preserve" and/or "snapshot_preserve_all"' } } },
target_preserve_daily => { default => 'all', accept => [ "all" ], accept_numeric => 1, target_preserve_daily => { default => 'all', accept => [ "all" ], accept_numeric => 1,
deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "snapshot_preserve" and/or "snapshot_preserve_all"' } } }, deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "target_preserve" and/or "target_preserve_all"' } } },
target_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1, target_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1,
deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "snapshot_preserve" and/or "snapshot_preserve_all"' } } }, deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "target_preserve" and/or "target_preserve_all"' } } },
target_preserve_monthly => { default => 'all', accept => [ "all" ], accept_numeric => 1, target_preserve_monthly => { default => 'all', accept => [ "all" ], accept_numeric => 1,
deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "snapshot_preserve" and/or "snapshot_preserve_all"' } } }, deprecated => { COMPAT_PRESERVE_ALL => 1, DEFAULT => { warn => 'Please use "target_preserve" and/or "target_preserve_all"' } } },
resume_missing => { default => "yes", accept => [ "yes", "no" ],
deprecated => { yes => { warn => 'ignoring' },
no => { warn => 'Please use "target_preserve_all latest" and "target_preserve no"',
replace_key => 'target_preserve',
replace_value => 'no',
} } },
snapshot_create_always => { default => undef, accept => [ "yes", "no" ], snapshot_create_always => { default => undef, accept => [ "yes", "no" ],
deprecated => { yes => { warn => "Please use \"snapshot_create always\"", deprecated => { yes => { warn => "Please use \"snapshot_create always\"",
replace_key => "snapshot_create", replace_key => "snapshot_create",
@ -4221,11 +4226,6 @@ MAIN:
my $preserve_latest = $svol->{SNAPSHOT_CREATED} ? 0 : 1; my $preserve_latest = $svol->{SNAPSHOT_CREATED} ? 0 : 1;
foreach my $droot (vinfo_subsection($svol, 'target')) { foreach my $droot (vinfo_subsection($svol, 'target')) {
#
# resume missing backups (resume_missing)
#
if(config_key($droot, "resume_missing"))
{
INFO "Checking for missing backups of subvolume \"$svol->{PRINT}\" in: $droot->{PRINT}/"; INFO "Checking for missing backups of subvolume \"$svol->{PRINT}\" in: $droot->{PRINT}/";
my @schedule; my @schedule;
my $resume_total = 0; my $resume_total = 0;
@ -4236,7 +4236,7 @@ MAIN:
unless($child->{BTRBK_DATE} && unless($child->{BTRBK_DATE} &&
($child->{SUBVOL_DIR} eq $snapdir) && ($child->{SUBVOL_DIR} eq $snapdir) &&
($child->{BTRBK_BASENAME} eq $snapshot_basename)) { ($child->{BTRBK_BASENAME} eq $snapshot_basename)) {
TRACE "Resume candidate does not match btrbk filename scheme, skipping: $child->{PRINT}"; TRACE "Backup candidate does not match btrbk filename scheme, skipping: $child->{PRINT}";
next; next;
} }
next if(scalar(get_receive_targets($droot, $child, exact_match => 1, warn_unexpected => 1))); next if(scalar(get_receive_targets($droot, $child, exact_match => 1, warn_unexpected => 1)));
@ -4245,7 +4245,7 @@ MAIN:
WARN "Target subvolume \"$err_vol->{PRINT}\" exists, but is not a receive target of \"$child->{PRINT}\""; WARN "Target subvolume \"$err_vol->{PRINT}\" exists, but is not a receive target of \"$child->{PRINT}\"";
} }
DEBUG "Adding resume candidate: $child->{PRINT}"; DEBUG "Adding backup candidate: $child->{PRINT}";
push(@schedule, { value => $child, push(@schedule, { value => $child,
btrbk_date => $child->{BTRBK_DATE}, btrbk_date => $child->{BTRBK_DATE},
# not enforcing resuming of latest snapshot anymore (since v0.23.0) # not enforcing resuming of latest snapshot anymore (since v0.23.0)
@ -4255,7 +4255,7 @@ MAIN:
if(scalar @schedule) if(scalar @schedule)
{ {
DEBUG "Checking schedule for resume candidates"; DEBUG "Checking schedule for backup candidates";
# add all present backups to schedule, with no value # add all present backups to schedule, with no value
# these are needed for correct results of schedule() # these are needed for correct results of schedule()
foreach my $vol (@{vinfo_subvol_list($droot)}) { foreach my $vol (@{vinfo_subvol_list($droot)}) {
@ -4279,13 +4279,12 @@ MAIN:
foreach my $child (sort { $a->{node}{cgen} <=> $b->{node}{cgen} } @resume) foreach my $child (sort { $a->{node}{cgen} <=> $b->{node}{cgen} } @resume)
{ {
INFO "Resuming subvolume backup (send-receive) for: $child->{PRINT}"; INFO "Creating subvolume backup (send-receive) for: $child->{PRINT}";
my ($latest_common_src, $latest_common_target) = get_latest_common($sroot, $child, $droot, $snapdir); my ($latest_common_src, $latest_common_target) = get_latest_common($sroot, $child, $droot, $snapdir);
if(macro_send_receive(source => $child, if(macro_send_receive(source => $child,
target => $droot, target => $droot,
parent => $latest_common_src, # this is <undef> if no common found parent => $latest_common_src, # this is <undef> if no common found
latest_common_target => $latest_common_target, latest_common_target => $latest_common_target,
resume => 1, # propagated to $droot->{SUBVOL_RECEIVED}
)) ))
{ {
$resume_success++; $resume_success++;
@ -4299,11 +4298,10 @@ MAIN:
} }
if($resume_total) { if($resume_total) {
INFO "Resumed $resume_success/$resume_total missing backups"; INFO "Created $resume_success/$resume_total missing backups";
} else { } else {
INFO "No missing backups found"; INFO "No missing backups found";
} }
} # /resume_missing
} }
} }
} }
@ -4493,7 +4491,6 @@ MAIN:
"--- deleted subvolume", "--- deleted subvolume",
"*** received subvolume (non-incremental)", "*** received subvolume (non-incremental)",
">>> received subvolume (incremental)", ">>> received subvolume (incremental)",
# "%>> received subvolume (incremental, resume_missing)",
], ],
); );

View File

@ -67,9 +67,8 @@ and backups, even if specified in the configuration file.
.PP .PP
\-r, \-\-resume-only \-r, \-\-resume-only
.RS 4 .RS 4
Resume only. Skips snapshot creation, only resumes missing Resume only. Skips snapshot creation, only resumes missing backups to
backups. This only makes sense if the \fIresume_missing\fR option is satisfy the target retention policy.
set to \[lq]yes\[rq] in the configuration file.
.RE .RE
.PP .PP
\-v, \-\-verbose \-v, \-\-verbose
@ -131,19 +130,17 @@ If the checks succeed, btrbk creates snapshots for all the source
subvolumes specified in the configuration file. subvolumes specified in the configuration file.
.PP .PP
Then, for each specified target, btrbk creates the backups as follows: Then, for each specified target, btrbk creates the backups as follows:
If the \fIresume_missing\fR option is set (the default), btrbk After the backups in the target directory are compared to the source
transfers all missing snapshots needed to satisfy the configured snapshots, btrbk transfers all missing snapshots needed to satisfy the
\fItarget_preserve\fR retention policy, incrementally from the latest configured target retention policy, incrementally from the latest
common parent subvolume found. If no common parent subvolume is found common parent subvolume found. If no common parent subvolume is found
(or if the \fIincremental\fR option is set to \[lq]no\[rq]), a full (or if the \fIincremental\fR option is set to \[lq]no\[rq]), a full
(non-incremental) backup is created. Note that the latest snapshot (non-incremental) backup is created.
(the one created in the first step) is always transferred, regardless
of the retention policy.
.PP .PP
As a last step, unless the \-p (\-\-preserve) option is set, snapshots As a last step, unless the \-p (\-\-preserve) option is set, snapshots
and backup subvolumes that are not preserved by their configured and backup subvolumes that are not preserved by their configured
retention policy will be deleted. Note that the latest snapshot as retention policy will be deleted. Note that the latest snapshot (the
well as the latest backup is always preserved, regardless of the one created in the first step) is always preserved, regardless of the
retention policy. retention policy.
.PP .PP
Use the \fI\-\-format\fR command line option to switch between Use the \fI\-\-format\fR command line option to switch between

View File

@ -110,9 +110,8 @@ if the source subvolume has changed since the last snapshot (more
precisely: if the btrfs generation has been increased since the last precisely: if the btrfs generation has been increased since the last
snapshot). If set to \[lq]always\[rq], snapshots are always snapshot). If set to \[lq]always\[rq], snapshots are always
created. If set to \[lq]no\[rq], the snapshots are never created created. If set to \[lq]no\[rq], the snapshots are never created
(useful in conjunction with the \fIresume_missing\fR option if another (useful if another instance of btrbk is taking care of snapshot
instance of btrbk is taking care of snapshot creation). Defaults to creation). Defaults to \[lq]always\[rq].
\[lq]always\[rq].
.RE .RE
.PP .PP
\fBincremental\fR yes|no|strict \fBincremental\fR yes|no|strict
@ -122,13 +121,6 @@ non-incremental (initial) backups are never created. Defaults to
\[lq]yes\[rq]. \[lq]yes\[rq].
.RE .RE
.PP .PP
\fBresume_missing\fR yes|no
.RS 4
If set, the backups in the target directory are compared to the source
snapshots, and missing backups are created if needed (complying to the
target preserve matrix). Defaults to \[lq]yes\[rq].
.RE
.PP
\fBsnapshot_preserve\fR <retention_policy> \fBsnapshot_preserve\fR <retention_policy>
.RS 4 .RS 4
Set retention policy for snapshots (see RETENTION POLICY below). Set retention policy for snapshots (see RETENTION POLICY below).