1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP5 Anyone see what I'm doing wrong in this small script ... am crying at the moment

Discussion in 'XenForo Development Discussions' started by Jethro, Nov 12, 2010.

  1. Jethro

    Jethro Well-Known Member

    $dbhost = 'host';
    $dbuser = 'user';
    $dbpass = 'password';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    $dbname = 'database';
    mysql_select_db($dbname) or die ("Database Selection Wrong");
    $backupfile = "holycowitsdata.sql";
    $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupfile";
    echo("done and dusted");
    It's generating the backupfile but is not actually dumping any data to it ....
    Dragonfly and anotheralias like this.
  2. anotheralias

    anotheralias Well-Known Member

    I can't help you obviously, but ... been there, so I Liked you since I can't hand you a shot of bourbon or something. (Or the whole bottle.)
    Dragonfly and Jethro like this.
  3. SchmitzIT

    SchmitzIT Well-Known Member

    Have you tried manually running the string generated by echo($command) from a shell window?
  4. Shadab

    Shadab Well-Known Member

    Dragonfly and Jethro like this.
  5. Elizabeth

    Elizabeth Well-Known Member

    It's the small things that will drive you crazy!
  6. g0rn

    g0rn Well-Known Member

    By the way, you do not need to connect to the database from the php script, you only need to execute mysqldump command and it will connect and dump everything itself.
    Floris likes this.
  7. Jethro

    Jethro Well-Known Member

    Thanks dude, working like a charm :)

    g0rn am opening the database to ensure I have the correct details as this small script is being run over multiple dbs for a full scale move. An open ensures I have the correct details each time it's run.

Share This Page