I run mysqldump from php with the necessary parameters, a file is created, everything is ok, but how do I know if everything really went well? After all, you never know what kind of failures will occur?
Answer 1, authority 100%
The dump is done in console mode by outputting the SQL script to STDOUT. This output is redirected to a file, and if at some stage there is a failure or a break in communication, then this file will not be appended to the end. Alternatively, you can check the file for the presence of
Dump completedon the last line.
The end of the dump file generated by
mysqldumplooks like this:
/*!40101 SET [email protected]_SQL_MODE */; /*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */; /*!40014 SET [email protected]_UNIQUE_CHECKS */; /*!40101 SET [email protected]_CHARACTER_SET_CLIENT */; /*!40101 SET [email protected]_CHARACTER_SET_RESULTS */; /*!40101 SET [email protected]_COLLATION_CONNECTION */; /*!40111 SET [email protected]_SQL_NOTES */; -- Dump completed on 2012-04-12 16:58:52
Answer 2, authority 50%
Use file_exists()to check if the generated dump file exists