Results 1 to 9 of 9

Thread: --all-databases backup

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default --all-databases backup

    This isn't working.
    Code:
    echo system("$path mysqldump --all-databases> all_databases.sql");
    It creates a file, but it's contents are:
    Usage: mysqldump [OPTIONS] database [tables]
    OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    OR mysqldump [OPTIONS] --all-databases [OPTIONS]
    For more options, use mysqldump --help
    I'm running XAMPP 2.0 on Linux.

    Edit: I also tried adding -HOST -uUSERNAME -pPASSWORD, and that didn't work, and I tried using the MySQL_connect() function, and that didn't work.
    Last edited by Jas; 03-08-2008 at 04:31 AM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    PHP Code:
    <?php
    include 'config.php';
    include 
    'opendb.php';

    $backupFile $dbname date("Y-m-d-H-i-s") . '.gz';
    $command "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass --all-databases | gzip > $backupFile";
    system($command);
    include 
    'closedb.php';
    ?>
    Ryan
    Sevierville, TN

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thanks for the response.

    I saw that page, and I still couldn't figure it out. For one, what's the contents of the included files? I imagine a MySQL connect and close in two of them, but what's the third?
    Last edited by Jas; 03-10-2008 at 06:45 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  4. #4
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Config.php

    PHP Code:
    <?php
    // This is an example of config.php
    $dbhost 'localhost';
    $dbuser 'root';
    $dbpass 'password';
    $dbname 'phpcake';
    ?>
    opendb.php

    PHP Code:
    <?php
    // This is an example opendb.php
    $conn mysql_connect($dbhost$dbuser$dbpass) or die                      ('Error connecting to mysql');
    mysql_select_db($dbname);
    ?>
    closedb.php

    PHP Code:


    <?php
    // an example of closedb.php
    // it does nothing but closing
    // a mysql database connection

    mysql_close($conn);
    ?>
    Ryan
    Sevierville, TN

  5. #5
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thank you very much! So you have to connect to MySQL and include the information in the --all-databases command? I'll try and see what happens.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  6. #6
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    This still didn't work:
    PHP Code:
    <?php
        $conn 
    MySQL_connect('localhost','username','password');
        
    MySQL_select_db('a_db');
        
    system("/opt/lampp/bin/mysqldump mysqldump --opt -h localhost -u username -p password --all-databases > backup.sql")
        or die(
    'DID NOT WORK!');
        
    MySQL_close($conn);
    ?>
    It prints:
    DID NOT WORK!
    And backup.sql's contents are:
    Usage: mysqldump [OPTIONS] database [tables]
    OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    OR mysqldump [OPTIONS] --all-databases [OPTIONS]
    For more options, use mysqldump --help
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  7. #7
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    You have mysqldump 2x's

    PHP Code:
    /opt/lampp/bin/mysqldump mysqldump 
    remove the second mysqldump at the end
    Ryan
    Sevierville, TN

  8. The Following User Says Thank You to NXArmada For This Useful Post:

    Jas (03-13-2008)

  9. #8
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thanks again, but now the file "backup.sql" is completely empty. Am I doing something else wrong?
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  10. #9
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thank you again for all of your help. After a few hours googling through forum after forum, I found the answers I was looking for-- turns out I had more then one problem. Some were related to the script, others were the server configurations. In any case, it works, so I'm happy
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

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
  •