Piping tar into gpg
f_philipp at fastmail.net
Thu Feb 21 08:50:29 CET 2013
Am 20.02.2013 23:40, schrieb Daniel Kahn Gillmor:
> On 02/20/2013 04:29 PM, Stefan Malte Schumacher wrote:
>> I want to create encrypted backups with tar and gpg, which I then want to
>> upload to my online storage. Strangely I can't get it working.
>> "find /mnt/raid/Dokumente/ -type f -print0 |tar cfzv | gpg --symmetric
>> --output 1.tar.gz.gpg"
> if you want to pipeline like this, i don't think you want the "f" flag
> for tar.
> I also don't think you're using find and tar together properly -- i
> think you want xargs in the mix.
> 0 dkg at alice:/tmp/cdtemp.cD3zXc$ find t -type f -print0 | xargs -0 tar
> czv | gpg --symmetric > foo.tgz.gpg
Better don't do that. If xargs receives too many arguments, it will call
tar multiple times. I don't think you can append tar files like that,
Better approach (in bash, at least):
tar --create --null --files-from=<(find ... -print0) | gpg ...
This also has the advantage that it works correctly if no matches are
found, i.e. it creates an empty archive instead of showing an error.
Alternatively use cpio which was explicitly built around the concept of
being used with find.
I would also get rid of the z option as gpg compresses, too.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 263 bytes
Desc: OpenPGP digital signature
More information about the Gnupg-users