Forum Moderators: coopster

Message Too Old, No Replies

php MYSQL to MYSQL Transfer?

         

briesm

6:24 pm on Jun 22, 2005 (gmt 0)

10+ Year Member



Hey all,
I've got a MYSQL Database, essentially I plan on having a script execute on a local timer that will check the database if there are any entries, if so it will grab all of them and insert them into a local mySQL database that is on that computer. Now, I believe I can do this using SOAP to call a php function off the web server.

MY QUESTION:
Does anyone know coding to Grab all entries in a MYSQL Database table, and essentially insert them into another MYSQL (Which would be local on the computer executing the script). I also plan on actually deleting any entries that have been grabbed and put on this local database.

Summary:
Basically, I'm constantly backing up a MYSQL Database, but not exactly. I'm adding whatever new stuff comes to a complete local MYSQL Database.

jatar_k

6:37 pm on Jun 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you don't need to use soap really, you could just connect remotely to the db abd use something like mysqldump [dev.mysql.com]

briesm

7:08 pm on Jun 22, 2005 (gmt 0)

10+ Year Member



Remotely connect? Is there a way to have say a php file be automatically run every 15 minutes which would connect and perform a dump into a local MYSQL Database?

Like Can I do something like this?

$link=mysql_connect ("#*$!", "xxxxxxx", "xxxxx") or die ('Could not connect to the database because: ' . mysql_error());

mysql_select_db ("dbName") or die ('Could not select database');

$result = mysql_query($sql) or die('Query failed: ' . mysql_error());

shell> mysqldump --databases db_name1 [db_name2 ...] > localdatabasePATH.sql

jatar_k

7:12 pm on Jun 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



something like that

you could also use a shell script to do it

just tar gz the whole darn directory and then shoot it over somewhere else ;)

onematchfire

7:40 pm on Jun 22, 2005 (gmt 0)

10+ Year Member



This allows for realtime transfer without having to stop access to your db while the dump occurs

[onlamp.com...]