I want to backup the complete database before having a php script playing around with its tables so I thought about using mysqldump.
I tried to run the mysqldump command with shell_exec() and to check if it was successfull like this:
$command = 'mysqldump -u username -ppassword database > /path/database.sql';
$result = shell_exec($command);
if(!is_null($result)) {
echo 'Error during backup';
else {
echo 'Database saved';
// rest of the php script to modify the database (create/drop tables etc)
}
But I noticed that $result is alwas null, even when I give a path where the file cannot be written (no existing directory, or something that should return a permission denied on the shell prompt).
What am I missing?