Edward Kay wrote:
hi all,

Im doing the following dump through PHP:

$output = shell_exec('mysqldump '. $db_database .' > '.
$backup_path.$filename);

It doesnt seem to work but when I run the exact same command (with
appropriate values) in the command line it creates the dump file. What
could be the reason for this?

Thanks in advance.

regards



It appears that it could be because the user that runs the scripts is
not allowed to. When I run them on the commandline, I run them as the
root user. Is this a common problem? What would the best way be to sort
this out keeping in mind security on the server?


If you are trying to automate backups of you database, set up a
cron job. I
have a shell script that dumps my databases, zips them and then
sends them
via FTP to a remote server. This is automatically run every 12 hours by
cron.

See http://en.wikipedia.org/wiki/Crontab for more info.

Edward




hi Edward,
yes I know of CRONtabs but wont this still leave us with the user
permission of running mysqldump? because essentially it will still be a
PHP file to run the shell command to create the dump file?

thanks

No, cron will typically run as root. You don't need to involve PHP.

It looks to me as if you are trying to use web scripting (PHP) to do the
sysadmin on your server, for which other methods are more suitable.

Edward

#1. You can run mysqldump with the same flags a the mysql command line... i.e. -u=<user> --password=<password>
#2. Crons run as the user that owns the crontab, not always root.
#3. Edward is right, PHP is a wonderful tool, not sure the tool was meant to do the types of things you are trying to do...unless you could fill us in with more details of what the purpose is, then we might be able to give more insight into how.

-B

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to