btrbk: action tree: make use of get_receive_targets()

pull/30/head
Axel Burri 2015-04-01 15:06:11 +02:00
parent 5e5a5d0aac
commit 654d68713b
1 changed files with 8 additions and 17 deletions

25
btrbk
View File

@ -1469,33 +1469,24 @@ MAIN:
} }
my $sroot_uuid = $vol_info{$sroot}->{$svol}->{node}->{uuid} || die; my $sroot_uuid = $vol_info{$sroot}->{$svol}->{node}->{uuid} || die;
foreach (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } (values %{$vol_info{$sroot}})) foreach my $snapshot (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } (values %{$vol_info{$sroot}}))
{ {
next unless($_->{node}->{parent_uuid} eq $sroot_uuid); next unless($snapshot->{node}->{parent_uuid} eq $sroot_uuid);
# next unless($_->{SUBVOL_PATH} =~ /^$snapdir/); # don't print non-btrbk snapshots # next unless($snapshot->{SUBVOL_PATH} =~ /^$snapdir/); # don't print non-btrbk snapshots
print "| ^-- $_->{SUBVOL_PATH}\n"; print "| ^-- $snapshot->{SUBVOL_PATH}\n";
my $snapshot = $_->{FS_PATH};
$snapshot =~ s/^.*\///;
my $snapshot_uuid = $_->{node}->{uuid} || die;
foreach my $config_target (@{$config_subvol->{TARGET}}) foreach my $config_target (@{$config_subvol->{TARGET}})
{ {
my $droot = $config_target->{droot} || die; my $droot = $config_target->{droot} || die;
next unless $vol_info{$droot}; next unless $vol_info{$droot};
$droot_compat{$droot} = 1 if($vol_btrfs_progs_compat{$droot});
if($vol_btrfs_progs_compat{$droot}) { foreach (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } get_receive_targets($droot, $snapshot)) {
$droot_compat{$droot} = 1; print "| | ^== $_->{FS_PATH}\n";
}
else {
foreach (sort { $a->{SUBVOL_PATH} cmp $b->{SUBVOL_PATH} } (values %{$vol_info{$droot}})) {
next unless($_->{node}->{received_uuid} eq $snapshot_uuid);
print "| | ^== $_->{FS_PATH}\n";
}
} }
} }
} }
} }
if(keys %droot_compat) { if(keys %droot_compat) {
print "NOTE: Received subvolumes (backups) will are not printed for targets:\n"; print "\nNOTE: Received subvolumes (backups) are guessed by subvolume name for targets:\n";
print " - " . join("\n - ", (sort keys %droot_compat)); print " - " . join("\n - ", (sort keys %droot_compat));
} }
print "\n"; print "\n";