Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PHP] Mysql Backup/Export

0 views
Skip to first unread message

Shane McBride

unread,
Nov 14, 2000, 2:41:30 PM11/14/00
to
Is there a way to backup a MySQL db with php? I looked at the MySQL site, but it looks like you need to shell access, and we currently do not get shell access.

Sorry if this is inappropriate post.


TIA,
Shane


Myke Hines

unread,
Nov 14, 2000, 2:48:05 PM11/14/00
to
well you can do this
$output = `/path/to/mysqldump -u root --password=god production >
/tmp/production.dmp`;

that should work.
myke


TIA,
Shane

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general...@lists.php.net
For additional commands, e-mail: php-gene...@lists.php.net
To contact the list administrators, e-mail: php-lis...@lists.php.net

Shane McBride

unread,
Nov 14, 2000, 4:31:36 PM11/14/00
to
I found this GREAT utilty. It works wonderful for exactly your/my situation.
Here's the link:

http://www.ov-m.com/mysqlphpbak/

You will need to know the correct paths to set up the .ini file, but after
that it is SMOOTH sailing...

Shane

Joe Stump

unread,
Nov 14, 2000, 4:33:12 PM11/14/00
to
This is what I have done in the past:

<?

$tables = array('accounts','data');
for($i = 0 ; $i < sizeof($tables) ; ++$i){
$sql = "SELECT * FROM ".$tables[$i];
$r = mysql_query($sql);
if(@mysql_num_rows($r)){
while($row = mysql_fetch_array($r)){
while(list($key,$val) = each($row)){
$fields[] = $$key;
$values[] = addslashes($val);
}

echo "INSERT INTO ".$tables[$i]." (".implode(',',$fields).") VALUES ('".implode('\',\'',$values)."'); \n";
}
}
}

?>

Put that in a file on your server and then from a unix box somewhere you can do
something like this in a crontab to back it up.

0 0 * * * lynx -source http://www.server.com/backup.php > backup.sql

--Joe

================================================================================
= Joe Stump joest...@yahoo.com http://www.miester.org =
================================================================================
"Real programmers don't comment their code.
It was hard to write, it should be hard to understand."

0 new messages