mysqldump via php

mysqldump via php

am 29.06.2006 12:38:51 von jeffreyb

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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mysqldump via php

am 29.06.2006 13:31:18 von Adrian Bruce

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
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: mysqldump via php

am 29.06.2006 15:01:58 von Bastien Koert

why no use phpmyadmin to admin the db?

Bastien


>From: Jeffrey
>To: PHP DB
>Subject: [PHP-DB] mysqldump via php
>Date: Thu, 29 Jun 2006 12:38:51 +0200
>
>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
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: mysqldump via php

am 29.06.2006 16:08:28 von MIGUEL ANTONIO GUIRAO AGUILAR

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
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos.

This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may b
e used or reproduced in any manner whatsoever.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mysqldump via php

am 30.06.2006 10:10:32 von jeffreyb

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
>>
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php