How to Create the mysql backup

Easy way to create the mysql backup file

<?php
/* Create the mysql backup file */

define(‘DB_NAME’, ‘databaseName’);

/** MySQL database username */

define(‘DB_USER’, ‘dataUser’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘dbPassword’);

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

$dbhost = DB_HOST;
$dbuser = DB_USER;
$dbpass = DB_PASSWORD;
$dbname = DB_NAME;
$sqlfile = $dbname . date(“Y-m-d”) . ‘.sql.gz’;
system(“mysqldump -h $dbhost -u $dbuser –password=$dbpass $dbname | gzip > $sqlfile”);
?>

One Comment

Leave a Reply