Re: mysqldump via php
| From: | Jeffrey | Date: | Fri, 30 Jun 2006 08:10:32 +0000 |
| Subject: | Re: mysqldump via php | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42139@lists.php.net to get a copy of this message | ||
Thanks all for the help!
exec() seems the best option.
Jeffrey
Miguel Guirao wrote:
You could use exec() within PHP! -----Original Message----- From: Adrian Bruce [mailto:abruce@stvincent.ac.uk] Sent: Jueves, 29 de Junio de 2006 06:31 a.m. To: Jeffrey Cc: PHP DB Subject: Re: [PHP-DB] mysqldump via php 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