Re: Mysql Backup/Export

From: Date: Tue, 14 Nov 2000 21:34:15 +0000
Subject: Re: Mysql Backup/Export
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25242@lists.php.net to get a copy of this message
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 On Tue, Nov 14, 2000 at 11:49:07AM -0800, Myke Hines wrote: > well you can do this > $output = `/path/to/mysqldump -u root --password=god production > > /tmp/production.dmp`; > > that should work. > myke > > -----Original Message----- > From: Shane McBride [mailto:php@riversidedesigns.net] > Sent: Saturday, November 11, 2000 8:48 PM > To: Php-General > Subject: [PHP] Mysql Backup/Export > > > 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 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net ================================================================================ = Joe Stump joestump98@yahoo.com http://www.miester.org = ================================================================================ "Real programmers don't comment their code. It was hard to write, it should be hard to understand."

« previous php.general (#25242) next »