M
M
Mendax2014-11-03 14:30:02
linux
Mendax, 2014-11-03 14:30:02

How to check the creation status of a tar archive?

Part of my backup script creates a tarball of the content I want to backup. The question actually is, how can you embed a check on the status of creating an archive? What came to my mind is checking the exit code:

/bin/tar -czvf $BACKUP $CONTENT >> $LOG
if [ $? != 0 ]; then
    cat $LOG | mail -s "$SITE backup failure!" $EMAIL
fi

But I very often receive letters with a log of creating an archive, in which there are no errors, i.e. the listing of files shows that all files were successfully packed into the archive. Any ideas?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
jcmvbkbc, 2014-11-03
@jcmvbkbc

/bin/tar -czvf $BACKUP $CONTENT >> $LOG
I very often get emails with a log of creating an archive that does not contain errors

maybe because you didn't stderr to the same file: &>> $LOG, something like that?

D
Don Kaban, 2014-11-04
@donkaban

/bin/tar -czvf $BACKUP $CONTENT || mail -s "$SITE backup failure!" $EMAIL
www.tldp.org/LDP/abs/html/ops.html#ORREF

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question