Here's the information I have:
I am working with a Linux based system using MySQL and PHP5. I need to be able to generate a mysqldump
from within a .php file, and then have that dump be stored in a file on the server in a location I would specify.
As I'm a PHP nooblet, I'd like someone to give me some assistance, guidance, or code, that would do what I require. This would have to be run remotely from the Internet.
MajorLeo's answer point me in the right direction but it didn't worked for me. I've found this site that follows the same approach and did work.
I hope it helps someone else!
If you want to create a backup to download it via the browser, you also can do this without using a file.
The php function passthru() will directly redirect the output of mysqldump to the browser. In this example it also will be zipped.
Pro: You don't have to deal with temp files.
Con: Won't work on Windows. May have limits with huge datasets.
Here you can find a comprehensive solution to dump mysql structure and data like in PMA (and without using exec, passthru etc.):
https://github.com/antarasi/MySQL-Dump-with-Foreign-keys
It is fork of dszymczuk project with my enhancements.
The usage is simple
works like a charm :-)
Please reffer to the following link which contains a scriptlet that will help you: http://davidwalsh.name/backup-mysql-database-php
Note: This script may contain bugs with NULL data types