title: Saving the database backup on server instead of pushing to user
body: <p>Below is how I am generating the MySql database backup and forcing it to be downloaded on the users computer:</p>
  
  <pre><code>    $DBUSER=$this-&gt;db-&gt;username;
      $DBPASSWD=$this-&gt;db-&gt;password;
      $DATABASE=$this-&gt;db-&gt;database;
  
      $filename = $DATABASE . "-" . date("Y-m-d_H-i-s") . ".sql.gz";
      $mime = "application/x-gzip";
  
      header( "Content-Type: " . $mime );
      header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
  
      // $cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";   
      $cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";
  
      // Instead of the above command, I have tried the following command to save to the server but it didn't save
      // $save_path = $_SERVER['DOCUMENT_ROOT'] . '/application/assets/db_backups/' . $filename;
      // $cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best &gt; " . $save_path;
  
      passthru( $cmd );
  </code></pre>
  
  <p>What I want is, instead of pushing to the user, <strong>save it on the server</strong>. How may I modify this to make the file be downloaded on the server?</p>