MySQL, PHP & HTML5 banner

The PHP system() function is used to execute an external program. Because MySQL already has a built-in tool for creating MySQL database backups, mysqldump, let’s use it from our PHP script:

include 'config.php';
include 'opendb.php';
$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
include 'closedb.php';


The following post offers an alternative to this strategy: How to use PHP To Backup & Restore a MySQL Database Table

By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.