Re: mysqldump via php
| From: | Adrian Bruce | Date: | Thu, 29 Jun 2006 11:31:18 +0000 |
| Subject: | Re: mysqldump via php | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42133@lists.php.net to get a copy of this message | ||
mysqldump is a .exe, and therefore it will not work within mysql_query();
You may be able to use mysqldump from PHP using the system function
check out http://uk.php.net/system
Ade
Jeffrey wrote:
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