I'm attempting to run a php script during a cron job to dump my MySQL database to a folder for a backup.
$DBHost = 'localhost';
$DBName = 'mydatabase';
$DBUser = 'myuser';
$DBPassword = 'mypassword';
$PATH = "/home/mysite/Backups/";
$FILE_NAME = "backup-" . date( "Y-m-d_H:i:s" ) . ".sql.gz";
exec( '/usr/local/bin/mysqldump -u ' . $DBName . ' -p' . $DBPassword . ' ' . $DBName . ' | gzip --best > ' . $PATH . $FILE_NAME );
But I keep getting the error:
sh: -c: line 0: unexpected EOF while looking for matching `)'
sh: -c: line 1: syntax error: unexpected end of file
I have checked all the )
and can't find any non-matching.
If I comment out the exec
command then I do not get the error.
Any one see what I am doing wrong?