Super User Asked by morpheous on September 6, 2020
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
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.
Correct answer by KeithB on September 6, 2020
One of the reason to get this errors for beginners is that They forget to perform operations in the directory where the files are present Go to that location and perform the command As my files are in desktop ~/Desktop# tar - cf done.tar abc xyz Where xyz and abc are files and we are storing those files in done.tar If we go and perform the command in other location we will get above error
Answered by Ravi Teja Mureboina on September 6, 2020
I had a similar issue untarring a file I had received. Turns out I didn't have permission to write the files in the archive owned by root. Using sudo fixed it.
Answered by ttwalkertt on September 6, 2020
I was having the same issue and none of the above answers worked for me. However, I found that running the following command worked:
tar -cpzf /backups/fullbackup.tar.gz --exclude=backups --exclude=proc --exclude=tmp --exclude=mnt --exclude=sys --exclude=dev --exclude=run /
The errors that were being referred to in tar: Exiting with failure status due to previous errors
can be identified by turning off the -v option. Upon review, the errors came from directories like /run
and /sys
.
By excluding these directories, it works just fine. Hope this helps anyone with a similar issue.
Answered by DomainsFeatured on September 6, 2020
Sometimes backing up files that might change during the backup like logfiles, you might find useful the tar option '--ignore-failed-read' (I'm on Debian Linux, not sure for non gnu tar).
Standard output and error can be redirected in 2 different files with something like:
LOGDIR='/var/log/mylogdir'
LOG=${LOGDIR}/backup.log
ERRLOG=${LOGDIR}/backup.error.log
DATE=$(date +%Y-%m-%d)
HOSTNAME=$(hostname)
DATA_DIRS='/etc /home /root'
tar --ignore-failed-read -f ${BACKUP_DIR}/${HOSTNAME}-${DATE}.tgz -cvz ${DATA_DIRS} > $LOG 2> $ERRLOG
I find this to be generally safe, but please be careful though as tar won't stop ...
Answered by Fabio Pedrazzoli on September 6, 2020
You have misunderstood an earlier answer. The problem is not the -
, it is where the f
is in your argument list.
tar cvfz target.tgz <files>
Will try to create an archive called "z", as that is the text after f
. The error message is because tar can't find "target.gz" to add to archive "z".
tar cvzf target.tgz <files>
Will correctly create target.tgz and add files to it. This is because target.tgz is the first text after the f
argument.
Answered by Thornbury on September 6, 2020
The problem is the f
argument. It takes the next value as the filename, so it must be the last argument:
tar cvzf output.tgz folder
or:
tar -cvzf output.tgz folder
These are both the same and don't produce an error.
Answered by Andrea Monni on September 6, 2020
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.
Answered by jack on September 6, 2020
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
Answered by Janne Pikkarainen on September 6, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP