I want to save error
if error comes, into a file. But error not redirecting into file.
I get below error and its not redirecting into file.
mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': View 'nextgendev_new.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
HOST="localhost"
PASS="aaaaa"
LOCAL_DIR="/userBackupDrive/backupDatabases/" #Modified local directory
DAY="`date +%a`"
DATE="`date +%F`"
USER="root"
for db in `mysql -h $HOST -u $USER -p$PASS -e "show databases"`
do
mysqldump --opt --routines --single-transaction -p$PASS -u $USER -h $HOST --databases $db | gzip -9 > $LOCAL_DIR$db.$DAY.sql.gz 2>>/var/log/failedJobs/mysqlCronJob.log
RESULT=$?
if [ $RESULT -eq 0 ] ; then
echo
else
echo "$DATE__ $db backup not successful" >> /var/log/failedJobs/dbError.log
fi
done