PHP/MySQL: is there a self-contained (simple!) script to do MySQL (entire) DB contents (and structure) backup

I've found several snippets and strategies on the web, but none that i see are complete/self-contained.

Icing on the cake would be to have the option for saving to a server-side filename, vs.  clientside (PC) local  harddisk

(p.s. i'm not concerned about compressing the data, but if that's easy too, ...)

thanks
willsherwoodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nplibCommented:
mysqldump -u root -pPASSWORD --all-databases --opt > filename.sql
0
RWJDComCommented:
I've always used phpMyAdmin (http://phpmyadmin.sourceforge.net) for doing backups from the web otherwise I would go with nplib's suggestion of using the mysqldump dump command, if you need to be able to run it from the web you can always create a php script to run the mysqldump command.
<?php
   system("mysqldump -uroot -pPASSWORD dbname > file.sql");
?>

Open in new window

0
willsherwoodAuthor Commented:
sorry i wasn't clear:  how can i do this from PHP.  I don't want to execute shell commands...

i think i'm looking for a script that loops thru all tables and dumps them...
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

nplibCommented:
you can't do it solely through php.

php wil allow you to run query's, and run shell commands,

but other then that, that is the best your gonna get.

you need to run a shell command in order to dump the db.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BenMorelCommented:
Hi,
If you don't want to system() something, there is no "clean" nor "easy" way to do this, I'm afraid.
Let's resume the different possibilities :
- Use mysqldump (above solution), must be used with a system() call or equivalent.
- Use SELECT * INTO OUTFILE 'file' FROM table; but that can only write csv-like files on your system.
- Use a homebrew function that would be able to query the db, table after table, row after row, determining the column types, collations, and so on, and generating SQL queries based on that. Scripts like this probably exist, although I'm not aware of any. I guess phpmyadmin works that way.

AFAIK, there is no "built-in" function to do that.

So the solution for you would be to find such a library, and to keep it up to date, because as mysql evolves, this sofware must also evolve to be able to dump all particularities of your tables !

Sorry for not being able to help more than that :)
Ben
0
willsherwoodAuthor Commented:
thanks to all.
i guess that's why i wasn't able to find a script!!
it seems like this would be a basic/common function to support
0
BenMorelCommented:
Why not starting your own open source project? ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.