I'd like to call mysqldump to create multiple backup files and then archive them in one tar.gz.
I am following this tutorial on mysqldump part: http://dev.mensfeld.pl/2013/04/backup-mysql-dump-all-your-mysql-databases-in-separate-files/ (at the end, it calls mysqldump in a loop for every database and creates one file at a time)
I can just save all files in temporary directory and 'then' put them into the archive, however, is there anyway how to skip this unnecessary temporary-directory part? I tried to learn about named pipes, thinking they may be what I need, however, haven't really understood them.
Best Answer
You could use the
-r
flag to tar to append a file to an existing archive. Since it's legal to append to an empty or non-existent archive, you could modify the looped instruction to be something likeThe file will have to exist temporarily, as it needs to have a filename inside the tar index for extraction purposes (if you sent all the files to it via a pipe, think about how they might extract) - but you don't need to collect them all together then tar them all up.