0

I found what I thought was a solution in this forum to being able to find my specific LOG files and then doing TAR.GZ on these files for a backup. However, when execute the command I'm getting an error. The command prior to the pipe works great and finds the files that I'm needing but when trying to create the backup file I blow up. Any suggestions/direction would be appreciated. Thanks.

Here is the command:

find /var/log/provenir -type f -name "*2014-09-08.log" | tar -cvzf backupProvLogFiles_20140908.tar.gz

Here is the error I'm getting:

find /var/log/provenir -type f -name "*2014-09-08.log" | tar -czvf backupProvLogFiles_20140908.tar.gz --null -T -
tar: Removing leading `/' from member names
tar: /var/log/provenir/BureauDE32014-09-08.log\n/var/log/provenir/DE_HTTP2014-09
-08.log\n/var/log/provenir/BureauDE22014-09-08.log\n/var/log/provenir/DE_HTTP220
14-09-08.log\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Melinda
  • 1,501
  • 5
  • 25
  • 58

3 Answers3

1

You can also use gzip to do so

find /var/log/provenir -type f -name "*2014-09-08.log" | gzip > tar -cvzf backupProvLogFiles_20140908.tar EDIT


EDIT

A better solution would be to use command substituion

tar -cvzf backupProvLogFiles_20140908.tar $(find /var/log/provenir -type f -name "*2014-09-08.log")
nu11p01n73R
  • 26,397
  • 3
  • 39
  • 52
  • Thanks for the gzip solution. It did create the tar.gz file I wanted HOWEVER, when I opened the tar.gz file I saw another directory called backupProvLogFiles_20140908.tar but there was nothing in there. Any suggestions? Thanks. – Melinda Oct 07 '14 at 18:54
  • i found a better solution. see the edit. As of gzip, i think i lost something in between. – nu11p01n73R Oct 08 '14 at 04:18
0

I think you mean something like this:

find . -name "*XYZ*" -type f -print | tar -cvz -T - -f SomeFile.tgz
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Unfortunately that did not work for me as I have to add multiple file to the tar.gz file and I got an error to add a -M but when I did, that bombed as well. I had to start working on a PROD issue and could not get back to it immediately. My apologies for not replying. I will try again. Thanks. – Melinda Oct 07 '14 at 11:54
0

I was finally able to find a solution just in case someone else might be looking for another option to answer this question:

find /var/log/provenir -type f -name "*2014-09-08.log" -print0 | tar -czvf /var/log/provenir/barchive/backupProvLogFile_20140908.tar.gz --null -T -

This worked great. The answer came from this post: Find files and tar them (with spaces)

Thanks again for the help I received.

Regards.

Community
  • 1
  • 1
Melinda
  • 1,501
  • 5
  • 25
  • 58