How to backup mysql using php, and shell script - the easy way -Follow @ggarron
As I was trying to find an easy way to backup a MySQL database with no ssh access to the server, there should be better ways, but i found this easy one.
You will need a Shell script, a .php script.
Ok, lets make this work
- First create a shell script with this line
mysqldump --opt -u [user_name] -p [database_name] | gzip > [backup_file].dump.gz
and name it, lets say:
- Now create the .php script that will call the shell script.
It will contain this:
and name it, for instance
Until this point this should work, just copy the two files using your ftp account in the root directory of your site.
Here comes the security issue, nobody wants that somebody discover this file and can get all you mysql database, so you have some options.
Create a complete server based security like shown here: http://www.pagetutor.com/keeper/http_authentication.html
Erase the files from your server once used, and upload them each time you may need to do a backup.