btrbk: show subvolumes names failed on send-receive in backup summary

pull/30/head
Axel Burri 2015-03-31 20:36:10 +02:00
parent 889d7f0289
commit 679a96495a
1 changed files with 26 additions and 13 deletions

39
btrbk
View File

@ -832,7 +832,7 @@ sub btrfs_send_receive($$$;$)
ERROR "Failed to send/receive btrfs subvolume: $src " . ($real_parent ? "[$real_parent]" : "") . " -> $target"; ERROR "Failed to send/receive btrfs subvolume: $src " . ($real_parent ? "[$real_parent]" : "") . " -> $target";
return undef; return undef;
} }
return "$target/$src_name"; return 1;
} }
@ -846,6 +846,13 @@ sub macro_send_receive($@)
INFO "Receiving from snapshot: $info{src}"; INFO "Receiving from snapshot: $info{src}";
# add info to $config->{subvol_received}
my $src_name = $info{src};
$src_name =~ s/^.*\///;
$info{received_name} = "$info{target}/$src_name";
$config->{subvol_received} //= [];
push(@{$config->{subvol_received}}, \%info);
if($incremental) if($incremental)
{ {
# create backup from latest common # create backup from latest common
@ -857,6 +864,7 @@ sub macro_send_receive($@)
} }
else { else {
WARN "Backup to $info{target} failed: no common parent subvolume found, and option \"incremental\" is set to \"strict\""; WARN "Backup to $info{target} failed: no common parent subvolume found, and option \"incremental\" is set to \"strict\"";
$info{ERROR} = 1;
$config->{ABORTED} = "No common parent subvolume found, and option \"incremental\" is set to \"strict\""; $config->{ABORTED} = "No common parent subvolume found, and option \"incremental\" is set to \"strict\"";
return undef; return undef;
} }
@ -866,16 +874,14 @@ sub macro_send_receive($@)
delete $info{parent}; delete $info{parent};
} }
$info{received_name} = btrfs_send_receive($info{src}, $info{target}, $info{parent}, $config); if(btrfs_send_receive($info{src}, $info{target}, $info{parent}, $config)) {
if($info{received_name}) {
$config->{subvol_received} //= [];
push(@{$config->{subvol_received}}, \%info);
return 1; return 1;
} else { } else {
$info{ERROR} = 1;
$config->{ABORTED} = "btrfs send/receive command failed"; $config->{ABORTED} = "btrfs send/receive command failed";
}
return undef; return undef;
} }
}
sub get_date_tag($) sub get_date_tag($)
@ -1586,9 +1592,12 @@ MAIN:
# resume missing backups (resume_missing) # resume missing backups (resume_missing)
if(config_key($config_target, "resume_missing")) if(config_key($config_target, "resume_missing"))
{ {
INFO "Checking for missing backups of subvolume \"$sroot/$svol\": $droot/"; INFO "Checking for missing backups of subvolume \"$sroot/$svol\" in: $droot/";
my $found_missing = 0; my $found_missing = 0;
foreach my $child (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } get_snapshot_children($sroot, $svol)) { foreach my $child (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } get_snapshot_children($sroot, $svol))
{
last if($config_target->{ABORTED});
if(scalar get_receive_targets_by_uuid($droot, $child->{node}->{uuid})) { if(scalar get_receive_targets_by_uuid($droot, $child->{node}->{uuid})) {
DEBUG "Found matching receive target for: $child->{FS_PATH}"; DEBUG "Found matching receive target for: $child->{FS_PATH}";
} }
@ -1611,6 +1620,7 @@ MAIN:
} }
else else
{ {
$found_missing++;
INFO "Resuming subvolume backup (send-receive) for: $child->{FS_PATH}"; INFO "Resuming subvolume backup (send-receive) for: $child->{FS_PATH}";
if(macro_send_receive($config_target, if(macro_send_receive($config_target,
src => $child->{FS_PATH}, src => $child->{FS_PATH},
@ -1622,10 +1632,9 @@ MAIN:
DEBUG("Updated latest common snapshots for: $sroot/$svol: src=$parent_snap"); DEBUG("Updated latest common snapshots for: $sroot/$svol: src=$parent_snap");
} }
else { else {
ERROR("Error while resuming backups, aborting resume chain"); # note: ABORTED flag is already set by macro_send_receive()
last; ERROR("Error while resuming backups, aborting");
} }
$found_missing++;
} }
} }
} }
@ -1637,6 +1646,9 @@ MAIN:
} }
} }
# skip creation if resume_missing failed
next if($config_target->{ABORTED});
# finally create the latest backup # finally create the latest backup
INFO "Creating subvolume backup (send-receive) for: $sroot/$svol"; INFO "Creating subvolume backup (send-receive) for: $sroot/$svol";
macro_send_receive($config_target, macro_send_receive($config_target,
@ -1798,9 +1810,10 @@ MAIN:
# } # }
foreach(@{$config_target->{subvol_received} // []}) { foreach(@{$config_target->{subvol_received} // []}) {
next unless $_; my $create_mode = "***";
my $create_mode = $_->{parent} ? ">>>" : "***"; $create_mode = ">>>" if($_->{parent});
substr($create_mode, 0, 1, '%') if($_->{resume}); substr($create_mode, 0, 1, '%') if($_->{resume});
$create_mode = "!!!" if($_->{ERROR});
print "$create_mode $_->{received_name}\n"; print "$create_mode $_->{received_name}\n";
} }