From d6910e43ea9e1de456f7b04f54e0b70c4c72f622 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Wed, 19 Oct 2022 11:03:43 +0200 Subject: [PATCH] btrbk: add append_to_file option in run_cmd --- btrbk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/btrbk b/btrbk index c92eece..e9380e6 100755 --- a/btrbk +++ b/btrbk @@ -849,6 +849,10 @@ sub run_cmd(@) die unless($href->{stream_sink}); $href->{cmd_text} = _safe_cmd([ '>', $href->{redirect_to_file} ], \@unsafe_cmd); } + elsif($href->{append_to_file}) { + die unless($href->{stream_sink}); + $href->{cmd_text} = _safe_cmd([ '>>', $href->{append_to_file} ], \@unsafe_cmd); + } elsif($href->{compress_stdin}) { # does nothing if already compressed correctly by stream_compress if($compressed && ($compression{$compressed->{key}}->{format} ne $compression{$href->{compress_stdin}->{key}}->{format})) { @@ -911,7 +915,7 @@ sub run_cmd(@) @decompress_in = (); # fixup redirect_to_file - if((scalar(@rsh_cmd_pipe) == 1) && ($rsh_cmd_pipe[0]->{redirect_to_file})) { + if((scalar(@rsh_cmd_pipe) == 1) && ($rsh_cmd_pipe[0]->{redirect_to_file} || $rsh_cmd_pipe[0]->{append_to_file})) { # NOTE: direct redirection in ssh command does not work: "ssh '> outfile'" # we need to assemble: "ssh 'cat > outfile'" unshift @rsh_cmd_pipe, { cmd_text => 'cat' };