I\'m trying to back a database via a PHP script using this one simple line:
passthru(\"/usr/bin/mysqldump --opt --host=localhost --user=\\\"myuser\\\" --password
If I can make an educated guess it's because the user that runs the php-script (ie. user the httpd is run as) doesn't have permission to write to /var/www/vhosts/mydomain.com/httpdocs/tools/
.
Though the user you are using to execute the command has.
STDERR
and STDOUT
To see if there is anything printed to STDERR
that is relevant to the problem, use the below snippet!
$tubes = array(
0 => array("pipe", "r"),
// print contents on STDOUT to file
1 => array("file", "/var/www/vhosts/mydomain.com/httpdocs/tools/dbbackup-2011-12-17.sql", "w"),
2 => array("pipe", "w")
);
$p_handle = proc_open (
"/usr/bin/mysqldump --opt --host=localhost --user=\"myuser\" --password=\"mypass\" db_name",
$tubes, $pipes
);
if (is_resource ($p_handle)) {
fclose ($pipes[0]);
$stderr_data = stream_get_contents ($pipes[2]); fclose($pipes[2]);
$proc_ret = proc_close ($p_handle);
echo "--------- STDERR:\n$stderr_data\n";
echo "------------ RET: $proc_ret\n";
} else {
die ("Unable to execute external resource, aborting!");
}
Have you checked the error_log
associated with your httpd
?