jdog
jdog

Reputation: 2539

pipe input into tar while combining directory while piping to another program without temporary file

I have the following command to tar a folder while sending it to aws s3:

  tar czf - /path/to/folder | aws s3 cp s3://bucket.file.tar.gz

I would like to add output from mysqldump to the folder, but without saving the file - even temporarily - in the folder structure.

Ideally I also don't want to save the output of tar temporarily somewhere else, both for general security concerns and to save disk space.

Upvotes: 2

Views: 458

Answers (1)

user2199860
user2199860

Reputation: 818

You can change the path of a file being added to a tar file like so:

tar -czf - --transform=s,Downloads,var/lib, Downloads/myfile.txt > out.gz

tar -tzf out.tgz
var/lib/myfile.txt

Upvotes: 1

Related Questions