DB backup

If you are looking for the database backup it script will help.

All Database Backup in Mysql:

$dbhost = 'localhost';                                          //localhost or ip

$dbname = '–all-databases';                               // Sample DB

$dbuser = 'pKsKdbUser98';                                //sample user

$dbpass = 'pk@dbuser$9#0987';                       //Sample Password

    

$backup_file = $_SERVER[‘DOCUMENT_ROOT’].'/dbBackup/backupDBCODE/AllLocalDB'.'-'. date("Y-m-d-H-i-s") . '.sql.gz';    

    

$command = "mysqldump –opt -h $dbhost -u $dbuser –password='$dbpass' $dbname | gzip > $backup_file";

exec($command, $output);

    

 //print_r($output);

    

 $changePermission = "chmod -Rf 777 $backup_file";

exec($changePermission);

Posted in MySQL | Tagged , , , , | Comments Off

Comments are closed.