1 backup.mysql.inc | protected BackupMySql::backupDatabaseToFile(BackupFile $file) |
Backup the databases to a file.
Return value
bool: TRUE is backup successful, FALSE otherwise.
Overrides BackupDatabase::backupDatabaseToFile
File
- core/
includes/ backup/ backup.mysql.inc, line 80 - Contains the BackupMySQL class.
Class
- BackupMySql
- Creates and restores backups from a MySQL database source.
Code
protected function backupDatabaseToFile(BackupFile $file) {
$lines = 0;
$include = $this->settings['include_tables'];
$exclude = $this->settings['exclude_tables'];
$nodata = $this->settings['nodata_tables'];
if ($file->open(TRUE)) {
$file->write($this->getSqlFileHeader());
$all_tables = $this->getTables();
$all_views = $this->getViews();
foreach ($all_tables as $table) {
if ($this->timeoutCheck()) {
return FALSE;
}
// If there are any included tables specified, they take precedence.
if ($include) {
$included_table = in_array($table['name'], $include);
}
else {
$included_table = !in_array($table['name'], $exclude);
}
if ($included_table) {
$file->write($this->getTableStructureSql($table));
$lines++;
if (!in_array($table['name'], $nodata)) {
$lines += $this->dumpTableDataSqlToFile($file, $table);
}
}
}
foreach ($all_views as $view) {
if ($this->timeoutCheck()) {
return FALSE;
}
if ($view['name'] && !isset($exclude[$view['name']])) {
$file->write($this->getViewCreateSql($view));
}
}
$file->write($this->getSqlFileFooter());
$file->close();
return $lines;
}
else {
return FALSE;
}
}