mirror of https://github.com/digint/btrbk
btrbk: added command line option "--progress", which simply pipes btrfs send through `pv`
parent
752dbc6157
commit
d8e8df0ebd
|
@ -1,6 +1,7 @@
|
||||||
btrbk-current
|
btrbk-current
|
||||||
|
|
||||||
* Added configuration option "ssh_port" (close: #39).
|
* Added configuration option "ssh_port" (close: #39).
|
||||||
|
* Added command line option "--progress" (close: #42).
|
||||||
|
|
||||||
btrbk-0.19.3
|
btrbk-0.19.3
|
||||||
|
|
||||||
|
|
35
btrbk
35
btrbk
|
@ -104,6 +104,7 @@ my %uuid_fs_map; # map UUID to URL
|
||||||
|
|
||||||
my $dryrun;
|
my $dryrun;
|
||||||
my $loglevel = 1;
|
my $loglevel = 1;
|
||||||
|
my $show_progress = 0;
|
||||||
my $err = "";
|
my $err = "";
|
||||||
|
|
||||||
my $ip_addr_match = qr/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/;
|
my $ip_addr_match = qr/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/;
|
||||||
|
@ -140,6 +141,7 @@ sub HELP_MESSAGE
|
||||||
print STDERR " -v, --verbose be verbose (set loglevel=info)\n";
|
print STDERR " -v, --verbose be verbose (set loglevel=info)\n";
|
||||||
print STDERR " -q, --quiet be quiet (do not print summary for the \"run\" command)\n";
|
print STDERR " -q, --quiet be quiet (do not print summary for the \"run\" command)\n";
|
||||||
print STDERR " -l, --loglevel=LEVEL set logging level (warn, info, debug, trace)\n";
|
print STDERR " -l, --loglevel=LEVEL set logging level (warn, info, debug, trace)\n";
|
||||||
|
print STDERR " --progress show progress bar on send-receive operation\n";
|
||||||
print STDERR "\n";
|
print STDERR "\n";
|
||||||
print STDERR "commands:\n";
|
print STDERR "commands:\n";
|
||||||
print STDERR " run [subvol...] perform backup operations as defined in the config file\n";
|
print STDERR " run [subvol...] perform backup operations as defined in the config file\n";
|
||||||
|
@ -916,6 +918,7 @@ sub btrfs_send_receive($$$)
|
||||||
my $snapshot_name = $snapshot_path;
|
my $snapshot_name = $snapshot_path;
|
||||||
$snapshot_name =~ s/^.*\///;
|
$snapshot_name =~ s/^.*\///;
|
||||||
INFO ">>> $target->{PRINT}/$snapshot_name";
|
INFO ">>> $target->{PRINT}/$snapshot_name";
|
||||||
|
print STDOUT "Receiving subvol: $target->{PRINT}/$snapshot_name\n" if($show_progress && (not $dryrun));
|
||||||
|
|
||||||
DEBUG "[btrfs] send/receive" . ($parent ? " (incremental)" : " (complete)") . ":";
|
DEBUG "[btrfs] send/receive" . ($parent ? " (incremental)" : " (complete)") . ":";
|
||||||
DEBUG "[btrfs] source: $snapshot->{PRINT}";
|
DEBUG "[btrfs] source: $snapshot->{PRINT}";
|
||||||
|
@ -928,18 +931,21 @@ sub btrfs_send_receive($$$)
|
||||||
push(@send_options, '-v') if($loglevel >= 3);
|
push(@send_options, '-v') if($loglevel >= 3);
|
||||||
push(@receive_options, '-v') if($loglevel >= 3);
|
push(@receive_options, '-v') if($loglevel >= 3);
|
||||||
|
|
||||||
my $ret = run_cmd(
|
my @cmd_pipe;
|
||||||
{
|
push @cmd_pipe, {
|
||||||
cmd => [ qw(btrfs send), @send_options, $snapshot_path ],
|
cmd => [ qw(btrfs send), @send_options, $snapshot_path ],
|
||||||
rsh => $snapshot_rsh,
|
rsh => $snapshot_rsh,
|
||||||
name => "btrfs send",
|
name => "btrfs send",
|
||||||
},
|
};
|
||||||
{
|
push @cmd_pipe, {
|
||||||
cmd => [ qw(btrfs receive), @receive_options, $target_path . '/' ],
|
cmd => [ '/usr/bin/pv' ],
|
||||||
rsh => $target_rsh,
|
} if($show_progress);
|
||||||
name => "btrfs receive",
|
push @cmd_pipe, {
|
||||||
},
|
cmd => [ qw(btrfs receive), @receive_options, $target_path . '/' ],
|
||||||
);
|
rsh => $target_rsh,
|
||||||
|
name => "btrfs receive",
|
||||||
|
};
|
||||||
|
my $ret = run_cmd(@cmd_pipe);
|
||||||
unless(defined($ret)) {
|
unless(defined($ret)) {
|
||||||
ERROR "Failed to send/receive btrfs subvolume: $snapshot->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $target->{PRINT}";
|
ERROR "Failed to send/receive btrfs subvolume: $snapshot->{PRINT} " . ($parent_path ? "[$parent_path]" : "") . " -> $target->{PRINT}";
|
||||||
return undef;
|
return undef;
|
||||||
|
@ -1456,6 +1462,7 @@ MAIN:
|
||||||
'quiet|q' => \$quiet,
|
'quiet|q' => \$quiet,
|
||||||
'verbose|v' => sub { $loglevel = 2; },
|
'verbose|v' => sub { $loglevel = 2; },
|
||||||
'loglevel|l=s' => \$loglevel,
|
'loglevel|l=s' => \$loglevel,
|
||||||
|
'progress' => \$show_progress,
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
VERSION_MESSAGE();
|
VERSION_MESSAGE();
|
||||||
|
@ -1479,6 +1486,10 @@ MAIN:
|
||||||
@config_src = ( $config_cmdline ) if($config_cmdline);
|
@config_src = ( $config_cmdline ) if($config_cmdline);
|
||||||
|
|
||||||
# check command line options
|
# check command line options
|
||||||
|
if($show_progress && (not -e '/usr/bin/pv')) {
|
||||||
|
WARN 'found option "--progress", but "pv" is not present: (please install "pv")';
|
||||||
|
$show_progress = 0;
|
||||||
|
}
|
||||||
my ($action_run, $action_info, $action_tree, $action_diff, $action_origin);
|
my ($action_run, $action_info, $action_tree, $action_diff, $action_origin);
|
||||||
my @subvol_args;
|
my @subvol_args;
|
||||||
my ($args_expected_min, $args_expected_max) = (0, 0);
|
my ($args_expected_min, $args_expected_max) = (0, 0);
|
||||||
|
|
|
@ -46,6 +46,9 @@ executing the "run" command.
|
||||||
\-l, \-\-loglevel <level>
|
\-l, \-\-loglevel <level>
|
||||||
Set the level of verbosity. Accepted levels are warn, info, debug,
|
Set the level of verbosity. Accepted levels are warn, info, debug,
|
||||||
and trace.
|
and trace.
|
||||||
|
.TP
|
||||||
|
\-\-progress
|
||||||
|
Show progress bar on send-receive operation.
|
||||||
.SH COMMANDS
|
.SH COMMANDS
|
||||||
.PP
|
.PP
|
||||||
.B run
|
.B run
|
||||||
|
|
Loading…
Reference in New Issue