I have written a little script that tars and compresses a list of directories + files.

The script appears to run succesfully, in that a useable .tar.gz file is created after the script runs.

However, I get this annoying message after the script finishes:

tar: Exiting with failure status due to previous errors

I do not see any error messages whilst the script is working, and like I said, the produced file can be uncompressed with no warnings/errors. Since I am using this as part of my backup, I want to make sure that I am not ignoring something serious.

What are the possible reasons that this error/warning message is being produced - and can I safely ignore it?. If I cant ignore it, what are the steps to diagnose and resolve the error?

I am running on Ubuntu 10.0.4

link|improve this question

70% accept rate
feedback

4 Answers

up vote 1 down vote accepted

You will get that message if, for any reason, tar can't add all of the specified files to the tar. One if the most common is not having read permission on one of the files. This could be a big problem since you are using this for backup. If you are using the -v flag, try leaving it off. This should reduce the output and let you see what is going on.

link|improve this answer
+1 for the suggestion (I was using the 'verbose' option previously). I found that there was a permission issue on at least one of the files. At least now I know how to resolve this. many thanks – morpheous Jul 29 '10 at 14:26
feedback

Usually you can ignore that message. If there are any changes (such as file deletions/creations/modifications) to underlying directory tree during tar creation, it will throw that message. Also if there special files like device nodes, fifos and so on, they will cause that warning.

Are you sure you can't see any culprit files? Try with tar cvfz yourtarball.tgz /your/path

link|improve this answer
feedback

I had the same problem. All i did was to remove the dash ("-") from the command.

Instead of typing it as

tar -cvfz output.tar.gz folder/

try typing it as

tar cvfz output.tar.gz folder/

I am unaware of why the dash was causing problems in my case but at least it worked.

link|improve this answer
feedback

You should have seen an error message while the program is running - perhaps you missed it?

If you want to see only error messages, try piping away stdout:

tar cvzf output.tgz input >/dev/null
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.