PHP Script to Backup MySQL database using Hosting Cron

This is the script to automatically backup MySQL database using hosting cron feature and PHP.

Download this file

For details and tutorials regarding the implementation,please refer to Developer Shed/Codewalkers/Web hosting tutorial. Link here:

DevShed tutorials
Codewalkers tutorials
Web hosting tutorials

And look for the related article (e.g. Backup and Restoring MySQL Database) on this topic that I wrote (author:Codex-m).

Summarized steps:

1.) Download script and configure connection parameters.

2.) Upload folder to server. It is recommended it should be above public_html folder (also known as “www” folder or “html” folder). The primary reason is to deny public access to the folder.

3.) Configure cron.

4.) Troubleshoot if necessary and download the MySQL database file.

Important: Use the following file permissions in your Linux server

1.) .htaccess – 644
2.) cronmysqlbackup folder – 755
3.) cronmysqlbackup.php -755


1.) Linux
2.) PHP 5
3.) MySQL database 5.0
4.) Apache web server
5.) Paid hosting account (php function such as system are enabled).

Note: You cannot use this script under free hosting accounts. Also refer to the cronmysqlbackup.php script for detailed procedure (commented on the script).

Related posts: