mysqldump via php
| From: | Jeffrey | Date: | Thu, 29 Jun 2006 10:38:51 +0000 |
| Subject: | mysqldump via php | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-42132@lists.php.net to get a copy of this message | ||
I would like to do a backup of an entire MySQL database via php. My thought was to use mysqldump, write the data to a file and save the file. However...
$query="mysqldump $dbase";
$result=mysql_query($query) or die(mysql_error());
...immediately results in an "error in your SQL syntax near mysqldump [database name]".
The reason I want to do a MySQL back up via php is that I have a web application in which the user can archive a project, which involves moving a lot data from one set of tables to another set of tables. The user can also delete a project, which removes lots of data from the DB altogether. Although there are lots of "Are you sure you really want to do this?" messages the user must click upon, I am sure I will eventually get a user telling me she accidentally archived/deleted stuff and can I help.
So, my thought was to do a incorporate a mysqldump in the archiving/delete page. That way there would be a snapshot of the pre-action db, making it easy to put things right.
Can you help with my query - or by suggesting an alternative solution?
Thanks,
Jeffrey