I run daily xtrabackups on several machines via Cron, and all the output is sent to my email thanks to the MAILTO=
directive in /etc/crontab
This setup is working, as I can verify if everything is fine by checking if the last line says “completed OK!”
However, the output of the xtrabackup command is very verbose; each email can be several MBs, and the content isn’t particularly useful unless some errors occur.
I didn’t find any flag in the docs to control the verbosity of the output.
What would be the best solution here? Discarding stdout and reading only stderr? Would that capture any error that might occur?
Hey @Francesco_Montanari,
What I see most people do is redirect the log output to a local file in the same dir as the backup, and then do something like tail -30
of the log to the email, which should capture any errors since the tool should exit rather quickly after an error.
In addition to what Matthew suggested I’d consider adjusting the script to check return codes.
xtrabackup ...
RESULT=$?
if [ $RESULT -ne 0 ]; then
-- backup failure steps
else
-- backup success steps
fi
or egrep 'CRIT|ERR' backup.log
and parse the output to generate alerting email accordingly.
Alternatively, you might want to use Holland backup framework & configure it for xtrabackup, you have configuration options for acting upon detection using failed-backup-commad.
Thanks,
K