I still have a slight problem because the tar command ends with an error : *(the same error is also present with adb, printf and tail).*
$ python3 adbackup.py > /tmp/mybackup.tgz $ tar tvzf /tmp/mybackup.tgz ... all my files are here :-) gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now
Why not keep the non-tar file long term and convert it to gzip'd tar format when required. That way you'll be able to improve your conversion over time, and not break if adb changes its format. That breakage could go unnoticed until it's too late to re-backup the data.
(printf ... && cat foo.ab) | tar ...