EDIT
Ok dla wszystkich tych ktory nie wiedza jak zrobic a maja taka potrzebe:
  1. <?php
  2. function create_backup_file($file_name_backup, $drop = false) {
  3.  
  4.            $file = fopen($file_name_backup, 'w+');
  5.            
  6.            $output = "# Czas wygenerowania: ".date('d-m-Y G:i')."r\n";
  7.            $output .= "# Wersja serwera: ".mysql_get_server_info()."r\n";
  8.            $output .= "# Wersja php: ".phpversion()."r\nr\n";
  9.            fwrite($file, $output);
  10.  
  11.            $query = 'SHOW TABLES';
  12.            $result = mysql_query($query);
  13.            while ($row = mysql_fetch_assoc($result)) foreach ($row as $table) {
  14.  
  15.            $struct_table[$table] = '';
  16.            $struct_table[$table] .= "r\nr\n# Struktura tabeli: ".$table."r\nr\nr\n";
  17.  
  18.            $query_struct_table = mysql_query("SHOW CREATE TABLE `$table`");
  19.            while($struct = mysql_fetch_row($query_struct_table)) {
  20.  
  21.             foreach($struct as $tbl)
  22.  
  23.               if($drop) {
  24.              
  25.               $struct_table[$table] .= 'DROP TABLE IF EXISTS `'.$table."`;r\n";
  26.               $struct_table[$table] .= $tbl. ";r\nr\n";
  27.             }
  28.             else $struct_table[$table] .= $tbl. ";r\nr\n";
  29.          }
  30.            
  31.            fwrite($file, $struct_table[$table]);
  32.  
  33.            $table_zaw = "-------------------------------r\n";
  34.            $table_zaw .= '- Zawartosc tabeli: '.$table."r\n";
  35.            $table_zaw .= "-------------------------------r\nr\nr\n";              
  36.  
  37.                fwrite($file, $table_zaw);
  38.                $result2 = mysql_query('SHOW COLUMNS FROM '.$table);
  39.                $col_names= '';
  40.  
  41.                while($row = mysql_fetch_array($result2)) $col_names .= "`$row[0]`".', ';
  42.  
  43.                $col_names = substr($col_names, 0, -2);
  44.                $result2 = mysql_query('SELECT * FROM '.$table);
  45.                $num = mysql_num_fields($result2);
  46.  
  47.                while($row2 = mysql_fetch_row($result2)) {
  48.  
  49.                    $values = '';
  50.                    for($i = 0; $i < $num; $i++) {
  51.  
  52.                     $type = mysql_field_type($result2, $i);
  53.                      if($type == "tinyint" || $type == "smallint" || $type == "mediumint" || $type == "int" || $type == "bigint" || $type == "timestamp") $values.= $row2[$i].', '; else $values .= "'$row2[$i]'".', ';
  54.                    }
  55.                    $values = substr($values, 0, -2);
  56.                    $insert = "INSERT INTO ".$table."(".$col_names.") VALUES(".$values.");r\n";
  57.                    fwrite($file, trim($insert, "\n"));
  58.                }
  59.            }
  60.            fclose($file);
  61. }
  62.  
  63.  
  64. function download_file($file_backup) {
  65.  
  66.            header('Content-type: application/x-unknown');
  67.            header('Content-Disposition: attachment; filename='.$file_backup);
  68.            header('Connection: close');
  69.            header('Expires: 0');
  70.            readfile($file_backup);
  71. }
  72. ?>

Jedyne co to dubluje jeszcze nazwe tabeli i nie wiem nadal dlaczego.

Tak wyglada kawalek zrzutu: http://wklej.org/id/16542/