Piping tar into gpg
Florian Philipp
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.
>
Correct.
> 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,
can you?
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.
Regards,
Florian Philipp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20130221/e62027a1/attachment.pgp>
More information about the Gnupg-users
mailing list