I tried to make simple php script to backup databes using mysqldump but i got this error:
mysqldump: Couldn't find table: ">"
And this is the function that i have write to make the job:
protected function dump($params, $dbs, $backup_folder)
{
if (!is_writable($backup_folder)) {
throw new Exception(sprintf('The backup folder is not writable: %s',
$backup_folder));
}
$backup_folder = trim($backup_folder, "/"); // be sure that there is no / at the end
$baseCmd = 'mysqldump --hex-blob --routines --skip-lock-tables -h%s -u%s -p%s %s > %s';
foreach ($dbs as $db) {
$dest = sprintf('%s/%s', $backup_folder,
$db . '_' . date('YmdHis') . '.sql');
$cmd = sprintf($baseCmd, $params['host'], $params['user'],
$params['password'], $db, $dest);
echo "Exec: $cmd: ";
$last = system(escapeshellcmd($cmd), $res);
echo $res;
if ( 0 !== $res) {
echo "Fail";
} else {
echo "Done
";
}
}
}
The command printed by this function give:
mysqldump --hex-blob --routines --skip-lock-tables -hdb-backup -uroot -pMyPwd my_db_name > backups/my_db_name_20151010232734.sql
When i execute this command from Shell it works very well but not from Php script.
My config is:
- My Desktop System Shell: Ubuntu 15.04
- Mysql Server: Mysql 5.6 installed in Ubuntu Server 15.04
- PHP version: 5.6.4
Any help ?
Thank you