Automated MySQL backup

Avatar
  • Answered
I'm trying to schedule a mysql backup from cron. The job runs (not a cron) problem, but the mysqldump is empty. The script I'm running in in php, has permissions of 755, and I'm on a shared hosting plan (pro).

Here's a snippet of code with the command I'm trying to execute. In the example below $message is always null and $retval is 0.

Are we allowed to run exec() or system() from php? Perhaps that is my problem. if not, is there a way for me to accomplish this in some other way, like a Perl script or something?

$command = "mysqldump -u{$dbUsername} -p{$dbPassword} $dbName | gzip > $backupPath";

$message = exec($command, $output, $retval);

echo "$backupFile :: $message :: $retval";
Avatar
Scott
Hello Igontech, It is best to have our Tier 2 or Systems team take a look at your specific script. They may have better ideas on setting up the code and what commands can and cannot be used when creating a Cron. To do so, you would need to contact our support department at [email protected] with that request. Be sure to validate your account with either the last 4 digits of the credit card on file, or the current Account Management Panel (AMP) password. Best Regards, Scott M