I get below error but exit code shows zero . Is there a way to get exit code of db error. Because I will need to send email alert on basis of exit code or db error
mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': View 'crais.v_comloc' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)
My attempt
#!/bin/bash -x
mysqldump --opt --routines --single-transaction -p654321 -uroot -hlocalhost crais 2>>/var/log/failedJobs/mysqlCronJob.log |gzip -9 >/userBackupDrive/backupDatabases/crais.sql.gz
RESULT=$?
echo "Output code for $db is : $RESULT "
if [ $RESULT -eq 0 ] ; then
echo
else
echo "$DATE__ $db backup not successful" >> /var/log/failedJobs/dbError.log
fi