SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    Berlin
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simple sql backup

    Can someone tell me, what I'm doing wrong in this tiny sql backup script? Why dosn't it work?

    PHP Code:
    <?php
    echo("<b>Starting MySQL Dump:</b> \n");
    exec("mysqldump --all -e -l -add-drop-table -host=localhost -user=root -password=XXXX databasename >/Library/WebServer/php/backup.sql");
    echo(
    "executed!<br>\n");
    ?>

    The
    PHP Code:
    mysqldump --all ---add-drop-table -host=localhost -user=root -password=XXXX databasename >/Library/WebServer/php/backup.sql 
    works in my Terminal...

    Thanks
    Fl÷zen

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably your user when logged into the terminal has write privs to /Library/WebServer/php/ but since your PHP script runs under a different user, that user probably can't write to that folder. You'll probably need to change permissions of that folder to allow the web server to write to it.

    How much access to server configuration stuff do you have access to? Could you make the folder writable for the web server user?

  3. #3
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    Berlin
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by freddydoesphp
    Probably your user when logged into the terminal has write privs to /Library/WebServer/php/ but since your PHP script runs under a different user, that user probably can't write to that folder. You'll probably need to change permissions of that folder to allow the web server to write to it.

    How much access to server configuration stuff do you have access to? Could you make the folder writable for the web server user?
    Thanks for the hint - I set the directory to 777, now it does create a file when I use the corrected script
    PHP Code:
    <?php
    echo("<b>Starting MySQL Dump:</b> \n");
    exec("mysqldump --all -e -l --add-drop-table --host=localhost --user=root --password=XXXX kabul > /Library/WebServer/php/backup.sql");
    echo(
    "executed!<br>\n");
    ?>
    but unfortunately the file is empty

    Any further idea? I have su rights on the system.

    Florian

  4. #4
    SitePoint Enthusiast RedRose's Avatar
    Join Date
    Jul 2003
    Location
    A Nice place on earth..
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Florian, check the file size.... if it is correct, then your file might simply be having the wrong extension but IT IS indeed a .sql file.

    just the wrong extension.


    I had this today....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •