I am trying to set up a cron task to back up our database. It is modest in size (less than 3 MB), but it is important that it be backed up.
I have created a php script to handle this, but it just produces an empty file. What am I doing wrong? (I set up a standard shell scrip to do the exact same thing with the same problem). It works just fine on my own internal LAMP server.
<?php $username = 'db_user';
$host = 'localhost';
$password = 'password';
$database = 'db_name';
$backup= date("D");
$command = "mysqldump -u $username --password=$password --host=$host --database $database | gzip > $backup.sql.gz";
exec($command);
The script is designed to produce a separate backup for every day of the week, hence the $backup variable.