I was working on a script that would mount a shared folder from my XP box, tar the contents of the share and then unmount the share. If there are any errors, it should email me (I know this isn't handled properly yet, but it sorta works).
Tar keeps exiting with a 1 because of a "tar: file changed as we read it" error. Tar still completes the archive and it looks correct (haven't MD5'd it yet), but it screws my script up.
Am I doing something wrong or is CIFS screwing me up or what? I don't want to ignore errors from tar in my script, but I don't want false positive emails either.
The script below is very rough.
Code:
#/bin/bash
PROGNAME=$(basename $0)
function error_handle
{
if [ "$?" = "0" ]; then
echo $?
else
echo "${PROGNAME}: ${1:-"Unknown Error $LINENO "}" > /storage2/picture_backups/errorlog.txt
/usr/sbin/sendemail -f XXXXXXXX@comcast.net -t backups@XXXXXX.com -u Backup Script Error `date +%Y_%m_%d_%H_%M`
-s smtp.XXXXXXX.net -o message-file=/storage2/picture_backups/errorlog.txt
exit 1
fi
}
mount -t cifs -o username=USERNAME,password=PASSWORD,ro //192.168.1.131/Pictures/PICTURES /storage2/temp > /dev/null & EPID=$!
wait $EPID
error_handle
tar -czvf /storage2/picture_backups/backup-`date +%Y_%m_%d_%H_%M`.tar.gz /storage2/temp/ >/dev/null & EPID=$!
wait $EPID
error_handle
umount /storage2/temp
error_handle
Any help would be, well, helpful.
Thanks.