You are here

function _backup_migrate_get_dump_sql in Backup and Migrate 5.2

Same name and namespace in other branches
  1. 5 backup_migrate.module \_backup_migrate_get_dump_sql()
  2. 6 backup_migrate.module \_backup_migrate_get_dump_sql()

Get the sql dump file. Returns a list of sql commands, one command per line. That makes it easier to import without loading the whole file into memory. The files are a little harder to read, but human-readability is not a priority

1 call to _backup_migrate_get_dump_sql()
backup_migrate_db_backup in includes/db.inc
Build the database dump file. Takes a list of tables to exclude and some formatting options.

File

includes/db.inc, line 59
General database dump/restore code for Backup and Migrate.

Code

function _backup_migrate_get_dump_sql($file, $exclude, $nodata) {
  if ($dst = fopen($file, "w")) {
    fwrite($dst, _backup_migrate_get_sql_file_header());
    $alltables = _backup_migrate_get_tables();
    foreach ($alltables as $table) {
      if ($table['Name'] && !isset($exclude[$table['Name']])) {
        fwrite($dst, _backup_migrate_get_table_structure_sql($table));
        if (!in_array($table['Name'], $nodata)) {
          _backup_migrate_dump_table_data_sql_to_handle($dst, $table);
        }
      }
    }
    fwrite($dst, _backup_migrate_get_sql_file_footer());
    fclose($dst);
    return TRUE;
  }
  else {
    return FALSE;
  }
}