How to fix "tar: Exiting with failure status due to previous errors"

Last updated on August 26, 2020 by Dan Nanni

Question: When I try to create an archive using tar command, it fails in the middle, and throws an error saying:
tar: Exiting with failure status due to previous errors.
What causes this error, and how can I solve this error?

If you encounter the following error while running tar command, the most likely reason is that you do not have read permission on one of the files you are trying to archive with tar.

tar: Exiting with failure status due to previous errors

Then how can we pin down the file(s) causing the errors, or identify any other cause?

The tar command should actually print out what those "previous errors" are, but you can easily miss printed error messages if you run tar in verbose mode (e.g., -cvf). To catch error messages more easily, you can filter out tar's stdout messages as follows.

$ tar cvfz backup.tgz my_program/ > /dev/null

You will then see only error messages sent by tar to stderr.

tar: my_program/src/lib/.conf.db.~lock~: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors

As you can see in the above example, the cause for the errors is indeed "denied read permission."

To solve the problem, simply adjust the permission of the problematic file (or remove it), and re-run tar.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean