LostNerd

Well-Known Member
Mar 12, 2014
258
12
18
Hastings, East Sussex, UK
cPanel Access Level
Root Administrator
Twitter
Hello,

Just to clarify... Are you attempting to backup a single database or every database on your cPanel/WHM server?

If you are trying to backup your databases in one account only, the Backup Manager is very helpful.
 

LostNerd

Well-Known Member
Mar 12, 2014
258
12
18
Hastings, East Sussex, UK
cPanel Access Level
Root Administrator
Twitter
Code:
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';

$backup_file = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass ".
           "test_db | gzip > $backup_file";

system($command);
?>
Something like this may work. Change it to your needs. However, I personally prefer using a program such as Navicat to perform backups for me.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

Note that you can also backup a database through the cPanel interface or using "mysqldump" from the command line.

Thank you.