- Timestamp:
- 02/20/12 14:50:27 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.10/backup/functions.inc/class.backup.php
r13184 r13484 179 179 //build command 180 180 $s = str_replace('server-', '', $i['path']); 181 $sql_file = $this->b['_tmpdir'] . '/' . 'mysql-' . $s . '.sql'; 181 182 $cmd[] = fpbx_which('mysqldump'); 182 183 $cmd[] = '--host=' . backup__($this->s[$s]['host']); … … 193 194 } 194 195 $cmd[] = ' --opt --skip-comments'; 195 //$cmd[] = ' > ' . $this->b['_tmpdir'] . '/' . 'mysql-' . $s . '.sql'; 196 197 // Need to grep out leading /* comments and SET commands as they create problems 198 // restoring using the PEAR $db class 199 // 200 $cmd[] = ' | '; 201 $cmd[] = fpbx_which('grep'); 202 $cmd[] = "-v '^\/\*\|^SET'"; 203 $cmd[] = ' > ' . $sql_file; 204 196 205 exec(implode(' ', $cmd), $file, $status); 197 198 //dont keep the file if the command failed somehow 206 unset($cmd, $file); 207 208 // remove file and log error information if it failed. 209 // 199 210 if ($status !== 0) { 200 unlink($this->b['_tmpdir'] . '/' . 'mysql-' . $s); 201 } else { 202 //remove comments from the file, otherwise we have difficulty restoring 203 foreach ($file as $f => $line) { 204 if (substr($line, 0, 2) == '/*' || substr($line, 0, 3) == 'SET') { 205 unset($file[$f]); 206 } 207 } 208 file_put_contents($this->b['_tmpdir'] . '/' . 'mysql-' . $s . '.sql', 209 implode("\n", $file)); 210 } 211 ; 212 unset($cmd, $file); 211 unlink($sql_file); 212 $error_string = sprintf( 213 _("Backup failed dumping SQL database [%s] to file [%s], you have a corrupted backup from server [%s]."), 214 backup__($this->s[$s]['dbname']), $sql_file, backup__($this->s[$s]['host']) 215 ); 216 backup_log($error_string); 217 freepbx_log(FPBX_LOG_FATAL, $error_string); 218 } 213 219 break; 214 220 case 'astdb': … … 220 226 } 221 227 } 222 223 224 228 } 225 229
