Re: mysqldump problem from PHP
| From: | David Giragosian | Date: | Mon, 23 Oct 2006 15:49:51 +0000 |
| Subject: | Re: mysqldump problem from PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243484@lists.php.net to get a copy of this message | ||
Angelo, as Brad says, you can pass user and password args to mysqldump from
an include file.
I run a php backup script via cron every night, then tar and compress and
store in various dirs out of the web tree.
I have the script if you'd like. It came from someone on the php-db list
years ago, and I'm not in any way claiming credit for it.
David
On 10/23/06, Brad Bonkoski <bbonkoski@mediaguide.com> wrote:
Edward Kay wrote:Whathi 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.sortcould be the reason for this? Thanks in advance. regardsIt 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 tobycron job. Ithis out keeping in mind security on the server?If you are trying to automate backups of you database, set up ahave a shell script that dumps my databases, zips them and thensends themvia FTP to a remote server. This is automatically run every 12 hoursNo, 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.phpcron. See http://en.wikipedia.org/wiki/Crontab for more info. Edwardhi 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