btrbk: action "archive": print created subdirectories on summary; cleanup

pull/88/head
Axel Burri 2016-04-16 17:13:19 +02:00
parent 5a06a85619
commit 689d3d1233
2 changed files with 14 additions and 8 deletions

View File

@ -15,6 +15,7 @@ btrbk-current
* Allow wildcards in subvolume section (close: #71).
* Propagate targets defined in "volume" or "root" context to all
"subvolume" sections (close: #78).
* Added "archive" command (close: #79).
* Added configuration option "rate_limit" (close: #72).
* Added "--print-schedule" command line option.
* Detect interrupted transfers of raw targets (close: #75).

21
btrbk
View File

@ -3442,7 +3442,7 @@ MAIN:
init_transaction_log(config_key($config, "transaction_log"));
my $src_url = $filter_args[0] || die;
my $target_url = $filter_args[1] || die;
my $archive_url = $filter_args[1] || die;
# FIXME: add command line options for preserve logic
$config->{SUBSECTION} = []; # clear configured subsections, we build them dynamically
@ -3452,9 +3452,9 @@ MAIN:
ERROR "Failed to fetch subvolume detail for '$src_root->{PRINT}'" . ($err ? ": $err" : "");
exit 1;
}
my $target_root = vinfo($target_url, $config);
unless(vinfo_init_root($target_root, resolve_subdir => 1)) {
ERROR "Failed to fetch subvolume detail for '$target_root->{PRINT}'" . ($err ? ": $err" : "");
my $archive_root = vinfo($archive_url, $config);
unless(vinfo_init_root($archive_root, resolve_subdir => 1)) {
ERROR "Failed to fetch subvolume detail for '$archive_root->{PRINT}'" . ($err ? ": $err" : "");
exit 1;
}
@ -3471,7 +3471,7 @@ MAIN:
my $subvol_dir = $vol->{SUBVOL_DIR};
next if($name_uniq{"$subvol_dir/$snapshot_name"});
$name_uniq{"$subvol_dir/$snapshot_name"} = 1;
my $droot_url = $target_url . ($subvol_dir eq "" ? "" : "/$subvol_dir");
my $droot_url = $archive_url . ($subvol_dir eq "" ? "" : "/$subvol_dir");
my $sroot_url = $src_url . ($subvol_dir eq "" ? "" : "/$subvol_dir");
my $config_sroot = { CONTEXT => "archive_source",
PARENT => $config,
@ -3503,9 +3503,10 @@ MAIN:
WARN "Skipping archive target \"$droot->{PRINT}\": $abrt";
next;
}
$droot->{SUBDIR_CREATED} = 1;
if($dryrun) {
# we need to fake this directory on dryrun
$droot->{node} = $target_root->{node};
$droot->{node} = $archive_root->{node};
$droot->{NODE_SUBDIR} = $subvol_dir;
}
else {
@ -3567,6 +3568,9 @@ MAIN:
foreach my $sroot (vinfo_subsection($config, 'archive_source')) {
foreach my $droot (vinfo_subsection($sroot, 'target', 1)) {
my @subvol_out;
if($droot->{SUBDIR_CREATED}) {
push @subvol_out, "++. $droot->{PRINT}/";
}
foreach(@{$droot->{SUBVOL_RECEIVED} // []}) {
my $create_mode = "***";
$create_mode = ">>>" if($_->{parent});
@ -3574,7 +3578,7 @@ MAIN:
push @subvol_out, "$create_mode $_->{received_subvolume}->{PRINT}";
}
if(ABORTED($droot) && (ABORTED($droot) ne "USER_SKIP")) {
push @subvol_out, "!!! Target \"$droot->{PRINT}\" aborted: " . ABORTED($droot);;
push @subvol_out, "!!! Target \"$droot->{PRINT}\" aborted: " . ABORTED($droot);
}
if($droot->{CONFIG}->{UNRECOVERABLE}) {
push(@unrecoverable, $droot->{CONFIG}->{UNRECOVERABLE});
@ -3588,7 +3592,8 @@ MAIN:
print_header(title => "Archive Summary",
time => $start_time,
legend => [
"--- deleted subvolume",
# "--- deleted subvolume",
"++. created directory",
"*** received subvolume (non-incremental)",
">>> received subvolume (incremental)",
],