Mysql – thesqldump just stops with no errors

MySQLscripting

Backing up 30 DB's with .sh script using mysqldump. 27 DB's backups succeed and are the same size each day but 3 DB's do not and seem to just stop randomly part way through the dump with no errors.

Here is the script

#!/bin/bash

appname=myapp

dbname=mydb

dbuser=myuser

dbpass=mypass

datestamp=`date +%d%m%y`

rm -f /var/backups/* > /dev/null 2>&1
mysqldump -u$dbuser -p$dbpass $dbname > /var/backups/$dbname-$datestamp.sql && gzip /var/backups/$dbname-$datestamp.sql

tar -zcf /var/backups/data-$datestamp.tar.gz /var/www/data > /dev/null 2>&1

tar -zcf /var/myapp-backups/myapp-$datestamp.tar.gz /var/www/myapp > /dev/null 2>&1

I have checked the failing DB's with Mysqlcheck and everything seems fine so now I am not sure where to look for errors

There is no errors my the var/log/mysql and there is an error.log written today at 06.32 which would be around the right time the cron runs but its empty

Any ideas
Thanks

Best Answer

To get errors logs while you're doing dumps, add -v and 2> log.txt:

mysqldump -v -u -p databasename > databasesqlfile.sql 2> log.txt

You can also enable detail logging in mysql configuraion and check those logs if you get error while doing dumps. Start mysql and run:

show variables like '%log%;

Also, in config file, enable following logs:

[mysqld]

log-bin

log

log-error

log-slow-queries

and restart mysql to apply changes.