Does mysqldump return error codes I can use on a Windows batch file with such code: if errorlevel 1
and so on?
I would like to verify the success or failure of a backup.
Thanks.
Mysqldump returns the following:
0 - Success
1 - Warning
2 - Exception
http://dev.mysql.com/doc/refman/5.5/en/error-types.html
So you should probably use if errorlevel 2
to ignore warnings and only handle errors (depending on your needs and what warnings might occur, of course). Something like this might work:
mysqldump.exe --user USERNAME --password=PASSWORD --database DATABASE > dump.sql
REM Check for error
if %ERRORLEVEL% NEQ 0 (goto ERROR)
echo MySQL was dumped successfully
goto :EOF
:ERROR
echo Error occured
exit