I want to use tar and ssh to send files as part of automated processes on ubuntu 14.04. I can send the file as follows:
tar -c large_test_file_10MB.txt.tar.gz | ssh -q 172.16.200.211 'tar -x'
But this doesn't allow me to monitor the transfer progress. I have managed to tar a file and write the progress to stdout with the command below:
tar -czf large_test_file_10MB.txt.tar.gz large_test_file_10MB.txt --record-size=10K --checkpoint=100 --checkpoint-action=exec='echo $TAR_CHECKPOINT"0kiB"'; FROMSIZE=`du -sk large_test_file_10MB.txt | cut -f 1`; printf "%dkiB\n" $FROMSIZE
it produces the following output:
1000kiB 2000kiB 3000kiB 4000kiB 5000kiB 6000kiB 7000kiB 8000kiB 9000kiB 9768kiB
But this doesn't allow me to pipe the file to ssh and view the progress at the same time. If I change the --checkpoint-action=exec command from
echo $TAR_CHECKPOINT"0kiB" >> progress.txt
the output just changes to
1000kiB >> progress.txt 2000kiB >> progress.txt 3000kiB >> progress.txt 4000kiB >> progress.txt 5000kiB >> progress.txt 6000kiB >> progress.txt 7000kiB >> progress.txt 8000kiB >> progress.txt 9000kiB >> progress.txt 9768kiB >> progress.txt
how can I get the --checkpoint-action=exec command to rather write to file than to stdout?
I know that I could possibly do this with a tool such as pv, but I would prefer to be able to run the command without installing additional software.