Warn about empty dumpfiles / huge table issue
Some months ago I had to restore a database from a gziped mysql dump. To my surprise, the dump was an empty file!
Luckily, I had also a mysql hotbackup so I had the opportunity inspect what went wrong with the dump. It happened that I had a huge table (~1.4GB) full of junk that somehow prevented mysqldump do the job.
At the time I was very busy to find what exactly was making mysqldump die: if it was a timeout, a memory issue, buffer size, etc. Neither I still have the original dump to test.
The first thing that passed in my mind was: how backupninja didn't told me that it had an empty dumpfile? Looking at the handler code, I just saw an exit status check:
output=`su $user -s /bin/bash -c "set -o pipefail ; $execstr" 2>&1` code=$? if [ "$code" == "0" ] then debug $output info "Successfully finished dump of mysql database $db" else warning $output warning "Failed to dump mysql databases $db" fi
Woudn't an additional size check also be needed? The handler could throw a warning in case of a zero-sized dump:
if [ ! -s "$dumpdir/${db}.sql" ]; then warning "Dump of mysql database $db has zero size" fi
(from redmine: created on 2011-11-17)