MySQL backup using PHP

I would like to be able to use PHP to create a local copy of my remote DB.

I can use phpMyAdmin to do this manually but would like to be able to execute the backup from a single php file. I have searched high and low to find a solution but without any luck!

Can anyone help?!

Thanking you in advance,

Glenn.

Anything you can do in Admin you can execute through PHP.

So youd need have a function that did the following

Find list of tables in database with

mysql_query("show_tables")

Then loop through each table in the returned array
firstly to get the structure of the table

mysql_query("show_create_table $table")

Save the result to a string

then to get the data

mysql_query("SELECT * FROM $table")

and step through the data making a INSERT statement to add to the create string

repeat process for each database table

mandes… mysqldump

Rudy

Its a command line function, also doesnt that command put the backup on the SQL server ?

Whilst its theroretically possible to access the command through PHP with the exec() or system() functions most hosted solutions I have found block these methods.

I stand to be corrected as usual :wink:

well, i don’t do php, but isn’t there some kind of EXEC capability?

Thank you Mandes.

Glenn.