Re: mysqldump
| From: | Joseph Szobody | Date: | Thu, 27 Feb 2003 03:54:38 +0000 |
| Subject: | Re: mysqldump | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137336@lists.php.net to get a copy of this message | ||
You need to use exec, system, etc. Here is a script that I recently put together. It backs up the
database, and pushes it as a download to the user.
<?php
$filename = "db_backup_" . date("n-j-y");
header("Content-Disposition: filename=$filename.sql");
header("Content-Type: application/force-download");
exec("mysqldump -c -q user -u webserver -ppassword", $sql);
for($i = 0; $i < count($sql); $i++) {
echo $sql[$i] . "\r\n";
}
?>
Hope this helps,
Joseph
"John Taylor-Johnston" <taylorjo@collegesherbrooke.qc.ca> wrote in message news:3E5D8961.1151D64C@collegesherbrooke.qc.ca...
> Anyone do MySQLDump using PHP ?
>
> http://www.mysql.com/doc/en/mysqldump.html
>
> My code is:
> mysqldump -u ****** -p ****** -A > /home/mybackups/dump_all.sql
>
> I would like to pull it off using PHP, remotely.
>
> $date = date ("Ymd");
> $to_path = "/home/MyBackups/$date/dump_all.sql";
>
> mysqldump -u ****** -p ****** -A > $to_path;
>
> mysqldump is not PHP?!
>
> John
>