btrbk: bugfix: do not read target btrfs tree on "btrbk snapshot --preserve"

If running "btrbk snapshot --preserve", there is no need to initialize
targets, and we don't want to warn and fail (exitcode=10) on missing
targets.
pull/235/head
Vít Novotný 2018-05-09 12:33:10 +02:00 committed by Axel Burri
parent 17f41118d3
commit c8fcb01bc2
2 changed files with 31 additions and 22 deletions

View File

@ -8,6 +8,8 @@ btrbk-0.27.0-dev
(close #217). Note that this change may result in (previously (close #217). Note that this change may result in (previously
preserved) backups to be deleted! preserved) backups to be deleted!
* Bugfix: add "btrfs filesystem usage" backend mapping (close #222). * Bugfix: add "btrfs filesystem usage" backend mapping (close #222).
* Bugfix: do not fail (exitcode=10) if targets are not accessible on
"btrfs snapshot --preserve".
* Enhance internal data structures: * Enhance internal data structures:
- Allow snapshot_dir to be a mountpoint. - Allow snapshot_dir to be a mountpoint.
- Search complete target tree for correlated subvolumes. - Search complete target tree for correlated subvolumes.

51
btrbk
View File

@ -5313,31 +5313,38 @@ MAIN:
} }
# read target btrfs tree # read target btrfs tree
foreach my $sroot (vinfo_subsection($config, 'volume')) { if($action_run && $skip_backups && $preserve_snapshots && $preserve_backups) {
foreach my $svol (vinfo_subsection($sroot, 'subvolume')) { # if running "btrbk snapshot --preserve", there is no need to
foreach my $droot (vinfo_subsection($svol, 'target')) { # initialize targets, and we don't want to fail on missing targets.
DEBUG "Initializing target section: $droot->{PRINT}"; DEBUG "Skipping target tree readin (preserving all snapshots and backups)";
my $target_type = $droot->{CONFIG}->{target_type} || die; }
if($target_type eq "send-receive") else {
{ foreach my $sroot (vinfo_subsection($config, 'volume')) {
unless(vinfo_init_root($droot, resolve_subdir => 1)) { foreach my $svol (vinfo_subsection($sroot, 'subvolume')) {
ABORTED($droot, "Failed to fetch subvolume detail" . ($err ? ": $err" : "")); foreach my $droot (vinfo_subsection($svol, 'target')) {
WARN "Skipping target \"$droot->{PRINT}\": $abrt"; DEBUG "Initializing target section: $droot->{PRINT}";
next; my $target_type = $droot->{CONFIG}->{target_type} || die;
if($target_type eq "send-receive")
{
unless(vinfo_init_root($droot, resolve_subdir => 1)) {
ABORTED($droot, "Failed to fetch subvolume detail" . ($err ? ": $err" : ""));
WARN "Skipping target \"$droot->{PRINT}\": $abrt";
next;
}
} }
} elsif($target_type eq "raw")
elsif($target_type eq "raw") {
{ unless(vinfo_init_raw_root($droot)) {
unless(vinfo_init_raw_root($droot)) { ABORTED($droot, "Failed to fetch raw target metadata" . ($err ? ": $err" : ""));
ABORTED($droot, "Failed to fetch raw target metadata" . ($err ? ": $err" : "")); WARN "Skipping target \"$droot->{PRINT}\": $abrt";
WARN "Skipping target \"$droot->{PRINT}\": $abrt"; next;
next; }
} }
}
if($config_override{FAILSAFE_PRESERVE}) { if($config_override{FAILSAFE_PRESERVE}) {
ABORTED($droot, $config_override{FAILSAFE_PRESERVE}); ABORTED($droot, $config_override{FAILSAFE_PRESERVE});
WARN "Skipping target \"$droot->{PRINT}\": $abrt"; WARN "Skipping target \"$droot->{PRINT}\": $abrt";
}
} }
} }
} }