mirror of https://github.com/digint/btrbk
btrbk: logging prints "..." on consecutive lines
parent
1f7773dddc
commit
67d24695f1
66
btrbk
66
btrbk
|
@ -374,17 +374,17 @@ END_HELP
|
||||||
#80-----------------------------------------------------------------------------
|
#80-----------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _log_cont { my $p = shift; print STDERR $p . join("\n${p}... ", @_) . "\n"; }
|
||||||
sub TRACE { if($loglevel >= 4) { print STDERR "... $_\n" foreach(@_) } }
|
sub TRACE { print STDERR map { "___ $_\n" } @_ if($loglevel >= 4) }
|
||||||
sub DEBUG { if($loglevel >= 3) { print STDERR "$_\n" foreach(@_) } }
|
sub DEBUG { _log_cont("", @_) if($loglevel >= 3) }
|
||||||
sub INFO { if($loglevel >= 2) { print STDERR "$_\n" foreach(@_) } }
|
sub INFO { _log_cont("", @_) if($loglevel >= 2) }
|
||||||
sub WARN { if($loglevel >= 1) { print STDERR "WARNING: $_\n" foreach(@_) } }
|
sub WARN { _log_cont("WARNING: ", @_) if($loglevel >= 1) }
|
||||||
sub ERROR { print STDERR "ERROR: $_\n" foreach(@_) ; }
|
sub ERROR { _log_cont("ERROR: ", @_) }
|
||||||
|
|
||||||
sub WARN_ONCE {
|
sub WARN_ONCE {
|
||||||
my $t = shift;
|
my $t = shift;
|
||||||
if($warn_once{$t}) { TRACE("WARNING(again): $t"); }
|
if($warn_once{$t}) { TRACE("WARNING(again): $t", @_); return 0; }
|
||||||
else { $warn_once{$t} = 1; WARN($t); }
|
else { $warn_once{$t} = 1; WARN($t, @_); return 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
sub VINFO {
|
sub VINFO {
|
||||||
|
@ -918,7 +918,7 @@ sub btrfs_filesystem_usage($)
|
||||||
filter_stderr => \&_btrfs_filter_stderr,
|
filter_stderr => \&_btrfs_filter_stderr,
|
||||||
);
|
);
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to fetch btrfs filesystem usage for: $vol->{PRINT}", map("... $_", @stderr);
|
ERROR "Failed to fetch btrfs filesystem usage for: $vol->{PRINT}", @stderr;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ sub btrfs_subvolume_find_new($$;$)
|
||||||
filter_stderr => \&_btrfs_filter_stderr,
|
filter_stderr => \&_btrfs_filter_stderr,
|
||||||
);
|
);
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to fetch modified files for: $vol->{PRINT}", map("... $_", @stderr);
|
ERROR "Failed to fetch modified files for: $vol->{PRINT}", @stderr;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,7 +1293,7 @@ sub btrfs_subvolume_snapshot($$)
|
||||||
);
|
);
|
||||||
end_transaction("snapshot", defined($ret));
|
end_transaction("snapshot", defined($ret));
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to create snapshot: $svol->{PRINT} -> $target_path", map("... $_", @stderr);
|
ERROR "Failed to create snapshot: $svol->{PRINT} -> $target_path", @stderr;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
return $target_vol;
|
return $target_vol;
|
||||||
|
@ -1393,7 +1393,7 @@ sub btrfs_subvolume_delete($@)
|
||||||
@deleted = () if($catch_count != (scalar keys %err_catch));
|
@deleted = () if($catch_count != (scalar keys %err_catch));
|
||||||
}
|
}
|
||||||
unless(scalar(@deleted)) {
|
unless(scalar(@deleted)) {
|
||||||
ERROR "Failed to match error messages from delete command, assuming nothing deleted", map("... $_", @stderr);
|
ERROR "Failed to match error messages from delete command, assuming nothing deleted", @stderr;
|
||||||
ERROR map("Possibly not deleted subvolume: $_->{PRINT}", @$targets);
|
ERROR map("Possibly not deleted subvolume: $_->{PRINT}", @$targets);
|
||||||
ERROR "Consider running 'btrbk prune -n'";
|
ERROR "Consider running 'btrbk prune -n'";
|
||||||
}
|
}
|
||||||
|
@ -1425,7 +1425,7 @@ sub btrfs_qgroup_destroy($@)
|
||||||
);
|
);
|
||||||
end_transaction($opts{type} // "qgroup_destroy", defined($ret));
|
end_transaction($opts{type} // "qgroup_destroy", defined($ret));
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to destroy qgroup \"$qgroup_id\" for subvolume: $vol->{PRINT}", map("... $_", @stderr);
|
ERROR "Failed to destroy qgroup \"$qgroup_id\" for subvolume: $vol->{PRINT}", @stderr;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
return $vol;
|
return $vol;
|
||||||
|
@ -1544,8 +1544,7 @@ sub btrfs_send_receive($$;$$$)
|
||||||
end_transaction("send-receive", not $send_receive_error);
|
end_transaction("send-receive", not $send_receive_error);
|
||||||
|
|
||||||
if($send_receive_error) {
|
if($send_receive_error) {
|
||||||
ERROR "Failed to send/receive subvolume: $snapshot->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $vol_received->{PRINT}";
|
ERROR "Failed to send/receive subvolume: $snapshot->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $vol_received->{PRINT}", @cmd_err;
|
||||||
ERROR map("... $_", @cmd_err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($is_garbled) {
|
if($is_garbled) {
|
||||||
|
@ -1696,7 +1695,7 @@ sub btrfs_send_to_file($$$;$$)
|
||||||
name => $kdf_backend_name
|
name => $kdf_backend_name
|
||||||
);
|
);
|
||||||
unless(defined($kdf_values)) {
|
unless(defined($kdf_values)) {
|
||||||
ERROR "Failed to generate session key for $key_target_text", map("... $_", @stderr);
|
ERROR "Failed to generate session key for $key_target_text", @stderr;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1828,8 +1827,7 @@ sub btrfs_send_to_file($$$;$$)
|
||||||
}
|
}
|
||||||
end_transaction("send-to-raw", defined($ret));
|
end_transaction("send-to-raw", defined($ret));
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to send btrfs subvolume to raw file: $source->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $vol_received->{PRINT}";
|
ERROR "Failed to send btrfs subvolume to raw file: $source->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $vol_received->{PRINT}", @cmd_err;
|
||||||
ERROR map("... $_", @cmd_err);
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -5211,11 +5209,11 @@ MAIN:
|
||||||
# NOTE: ssh://{src,target} uses default config
|
# NOTE: ssh://{src,target} uses default config
|
||||||
|
|
||||||
my $src_vol = vinfo($src_url, $config);
|
my $src_vol = vinfo($src_url, $config);
|
||||||
unless(vinfo_init_root($src_vol)) { ERROR "Failed to fetch subvolume detail for '$src_vol->{PRINT}'", map("... $_", @stderr); exit 1; }
|
unless(vinfo_init_root($src_vol)) { ERROR "Failed to fetch subvolume detail for '$src_vol->{PRINT}'", @stderr; exit 1; }
|
||||||
if($src_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $src_vol->{PRINT}"; exit 1; }
|
if($src_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $src_vol->{PRINT}"; exit 1; }
|
||||||
|
|
||||||
my $target_vol = vinfo($target_url, $config);
|
my $target_vol = vinfo($target_url, $config);
|
||||||
unless(vinfo_init_root($target_vol)) { ERROR "Failed to fetch subvolume detail for '$target_vol->{PRINT}'", map("... $_", @stderr); exit 1; }
|
unless(vinfo_init_root($target_vol)) { ERROR "Failed to fetch subvolume detail for '$target_vol->{PRINT}'", @stderr; exit 1; }
|
||||||
if($target_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $target_vol->{PRINT}"; exit 1; }
|
if($target_vol->{node}{is_root}) { ERROR "Subvolume is btrfs root: $target_vol->{PRINT}"; exit 1; }
|
||||||
|
|
||||||
unless(_is_same_fs_tree($src_vol->{node}, $target_vol->{node})) {
|
unless(_is_same_fs_tree($src_vol->{node}, $target_vol->{node})) {
|
||||||
|
@ -5296,7 +5294,7 @@ MAIN:
|
||||||
# map url to real path (we need to match against mount points below)
|
# map url to real path (we need to match against mount points below)
|
||||||
my $root_path = system_realpath($root_vol);
|
my $root_path = system_realpath($root_vol);
|
||||||
unless($root_path) {
|
unless($root_path) {
|
||||||
ERROR "Cannot find real path for: $root_vol->{PATH}";
|
ERROR "Cannot find real path for: $root_vol->{PATH}", @stderr;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
$root_vol = vinfo($root_path, $config);
|
$root_vol = vinfo($root_path, $config);
|
||||||
|
@ -5317,7 +5315,7 @@ MAIN:
|
||||||
$realpath_cache{$mnt->{mount_point}} = $mnt->{mount_point}; # we know those are real paths, prevents calling readlink in btrfs_mountpoint
|
$realpath_cache{$mnt->{mount_point}} = $mnt->{mount_point}; # we know those are real paths, prevents calling readlink in btrfs_mountpoint
|
||||||
my $vol = vinfo($mnt->{mount_point}, $config);
|
my $vol = vinfo($mnt->{mount_point}, $config);
|
||||||
unless(vinfo_init_root($vol)) {
|
unless(vinfo_init_root($vol)) {
|
||||||
ERROR "Failed to fetch subvolume detail for: $vol->{PRINT}", map("... $_", @stderr);
|
ERROR "Failed to fetch subvolume detail for: $vol->{PRINT}", @stderr;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5397,12 +5395,12 @@ MAIN:
|
||||||
|
|
||||||
my $src_root = vinfo($src_url, $config);
|
my $src_root = vinfo($src_url, $config);
|
||||||
unless(vinfo_init_root($src_root)) {
|
unless(vinfo_init_root($src_root)) {
|
||||||
ERROR "Failed to fetch subvolume detail for '$src_root->{PRINT}'", map("... $_", @stderr);
|
ERROR "Failed to fetch subvolume detail for '$src_root->{PRINT}'", @stderr;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
my $archive_root = vinfo($archive_url, $config);
|
my $archive_root = vinfo($archive_url, $config);
|
||||||
unless($archive_raw ? vinfo_init_raw_root($archive_root) : vinfo_init_root($archive_root)) {
|
unless($archive_raw ? vinfo_init_raw_root($archive_root) : vinfo_init_root($archive_root)) {
|
||||||
ERROR "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$archive_root->{PRINT}'", map("... $_", @stderr);
|
ERROR "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$archive_root->{PRINT}'", @stderr;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5438,7 +5436,7 @@ MAIN:
|
||||||
vinfo_assign_config($sroot);
|
vinfo_assign_config($sroot);
|
||||||
unless(vinfo_init_root($sroot)) {
|
unless(vinfo_init_root($sroot)) {
|
||||||
ABORTED($sroot, "Failed to fetch subvolume detail");
|
ABORTED($sroot, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping archive source \"$sroot->{PRINT}\": " . ABORTED_TEXT($sroot), map("... $_", @stderr);
|
WARN "Skipping archive source \"$sroot->{PRINT}\": " . ABORTED_TEXT($sroot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5448,7 +5446,7 @@ MAIN:
|
||||||
DEBUG "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$droot->{PRINT}'";
|
DEBUG "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$droot->{PRINT}'";
|
||||||
unless(system_mkdir($droot)) {
|
unless(system_mkdir($droot)) {
|
||||||
ABORTED($droot, "Failed to create directory: $droot->{PRINT}/");
|
ABORTED($droot, "Failed to create directory: $droot->{PRINT}/");
|
||||||
WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), map("... $_", @stderr);
|
WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$droot->{SUBDIR_CREATED} = 1;
|
$droot->{SUBDIR_CREATED} = 1;
|
||||||
|
@ -5462,7 +5460,7 @@ MAIN:
|
||||||
# after directory is created, try to init again
|
# after directory is created, try to init again
|
||||||
unless($archive_raw ? vinfo_init_raw_root($droot) : vinfo_init_root($droot)) {
|
unless($archive_raw ? vinfo_init_raw_root($droot) : vinfo_init_root($droot)) {
|
||||||
ABORTED($droot, "Failed to fetch subvolume detail");
|
ABORTED($droot, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), map("... $_", @stderr);
|
WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5642,7 +5640,7 @@ MAIN:
|
||||||
$sroot_glob = vinfo($config_vol->{url}, $config_vol);
|
$sroot_glob = vinfo($config_vol->{url}, $config_vol);
|
||||||
unless(vinfo_init_root($sroot_glob)) {
|
unless(vinfo_init_root($sroot_glob)) {
|
||||||
ABORTED($sroot_glob, "Failed to fetch subvolume detail");
|
ABORTED($sroot_glob, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping subvolume (wildcards) \"$sroot_glob->{PRINT}/$globs\": " . ABORTED_TEXT($sroot_glob), map("... $_", @stderr);
|
WARN "Skipping subvolume (wildcards) \"$sroot_glob->{PRINT}/$globs\": " . ABORTED_TEXT($sroot_glob), @stderr;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5975,14 +5973,14 @@ MAIN:
|
||||||
DEBUG "Initializing volume section: $sroot->{PRINT}";
|
DEBUG "Initializing volume section: $sroot->{PRINT}";
|
||||||
unless(vinfo_init_root($sroot)) {
|
unless(vinfo_init_root($sroot)) {
|
||||||
ABORTED($sroot, "Failed to fetch subvolume detail");
|
ABORTED($sroot, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping volume \"$sroot->{PRINT}\": " . ABORTED_TEXT($sroot), map("... $_", @stderr);
|
WARN "Skipping volume \"$sroot->{PRINT}\": " . ABORTED_TEXT($sroot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
foreach my $svol (vinfo_subsection($sroot, 'subvolume')) {
|
foreach my $svol (vinfo_subsection($sroot, 'subvolume')) {
|
||||||
DEBUG "Initializing subvolume section: $svol->{PRINT}";
|
DEBUG "Initializing subvolume section: $svol->{PRINT}";
|
||||||
unless(vinfo_init_root($svol)) {
|
unless(vinfo_init_root($svol)) {
|
||||||
ABORTED($svol, "Failed to fetch subvolume detail");
|
ABORTED($svol, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping subvolume \"$svol->{PRINT}\": " . ABORTED_TEXT($svol), map("... $_", @stderr);
|
WARN "Skipping subvolume \"$svol->{PRINT}\": " . ABORTED_TEXT($svol), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if((not $svol->{node}{uuid}) || ($svol->{node}{uuid} eq '-')) {
|
if((not $svol->{node}{uuid}) || ($svol->{node}{uuid} eq '-')) {
|
||||||
|
@ -6013,7 +6011,7 @@ MAIN:
|
||||||
my $snaproot = vinfo_snapshot_root($svol);
|
my $snaproot = vinfo_snapshot_root($svol);
|
||||||
unless(vinfo_init_root($snaproot)) {
|
unless(vinfo_init_root($snaproot)) {
|
||||||
ABORTED($svol, "Failed to fetch subvolume detail for snapshot_dir");
|
ABORTED($svol, "Failed to fetch subvolume detail for snapshot_dir");
|
||||||
WARN "Skipping subvolume \"$svol->{PRINT}\": " . ABORTED_TEXT($svol), map("... $_", @stderr);
|
WARN "Skipping subvolume \"$svol->{PRINT}\": " . ABORTED_TEXT($svol), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
unless(_is_same_fs_tree($snaproot->{node}, $svol->{node})) {
|
unless(_is_same_fs_tree($snaproot->{node}, $svol->{node})) {
|
||||||
|
@ -6040,7 +6038,7 @@ MAIN:
|
||||||
{
|
{
|
||||||
unless(vinfo_init_root($droot)) {
|
unless(vinfo_init_root($droot)) {
|
||||||
ABORTED($droot, "Failed to fetch subvolume detail");
|
ABORTED($droot, "Failed to fetch subvolume detail");
|
||||||
WARN "Skipping target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), map("... $_", @stderr);
|
WARN "Skipping target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6048,7 +6046,7 @@ MAIN:
|
||||||
{
|
{
|
||||||
unless(vinfo_init_raw_root($droot)) {
|
unless(vinfo_init_raw_root($droot)) {
|
||||||
ABORTED($droot, "Failed to fetch raw target metadata");
|
ABORTED($droot, "Failed to fetch raw target metadata");
|
||||||
WARN "Skipping target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), map("... $_", @stderr);
|
WARN "Skipping target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot), @stderr;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6098,7 +6096,7 @@ MAIN:
|
||||||
my $url = $subvol_args[0] || die;
|
my $url = $subvol_args[0] || die;
|
||||||
my $vol = vinfo($url, $config);
|
my $vol = vinfo($url, $config);
|
||||||
unless(vinfo_init_root($vol)) {
|
unless(vinfo_init_root($vol)) {
|
||||||
ERROR "Failed to fetch subvolume detail for: $url", map("... $_", @stderr);
|
ERROR "Failed to fetch subvolume detail for: $url", @stderr;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
if($vol->{node}{is_root}) {
|
if($vol->{node}{is_root}) {
|
||||||
|
|
Loading…
Reference in New Issue