Powered by MySQL logo

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:

<?php
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";
system($command);
include 'closedb.php';
?>

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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