title: Trouble with mysqldump when backing up db as xml
body: <p>I'm trying to backup one of my databases with <code>mysqldump</code> and I'm trying to export it to an xml file which already exists. Here is what I have:</p>
  
  <pre><code>&lt;?php
  $dbUser = 'user';    // db User
  $dbPass = 'pass';    // db User Password
  $dbName = 'db';      // db name
  $dest   = $_SERVER['DOCUMENT_ROOT'] . 'backup'; // Path to directory
  
  class MySQLDump {
  private $cmd;
  
  function MySQLDump($dbUser,$dbPass,$dbName,$dest) {
      $fname = $dbName.'.xml';
      $this-&gt;cmd='mysqldump -X -u'.$dbUser.' -p'.$dbPass.' '.$dbName.
          ' &gt;'.$dest.'/'.$fname;
  }
  
  public function backup() {
      system($this-&gt;cmd, $error);
      if($error) {
          trigger_error ('Backup failed: ' . $error . '&lt;br /&gt;Attempted: ' . $this-&gt;cmd);
      }
  }
  } // end class def
  
  $mysqlDump = new MySQLDump($dbUser, $dbPass, $dbName, $dest);  
  $mysqlDump-&gt;backup();
  ?&gt;
  </code></pre>
  
  <p>This always generates the error thrown in the <code>backup</code> function. Here is a sample of <code>$cmd</code>'s output:</p>
  
  <pre><code>mysqldump -X -udan -pdanPass danDB &gt;/var/www/prod/dan/web/backup/danDB.xml
  </code></pre>
  
  <p>Any idea what's going wrong? I've never really used <code>mysqldump</code> so I'm not sure if I'm approaching this correctly. Any help is greatly appreciated.</p>