You are here

function _backup_migrate_dump_tables in Backup and Migrate 5

Same name and namespace in other branches
  1. 6 backup_migrate.module \_backup_migrate_dump_tables()

Build the database dump file. Takes a list of tables to exclude and some formatting options.

3 calls to _backup_migrate_dump_tables()
backup_migrate_backup_submit in ./backup_migrate.module
Submit the form. Save the values as defaults if desired and output the backup file.
backup_migrate_cron in ./backup_migrate.module
Implementation of hook_cron(),
_backup_migrate_backup_with_defaults in ./backup_migrate.module
Backup the database with the default settings.

File

./backup_migrate.module, line 499
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (f.e. cache_*)

Code

function _backup_migrate_dump_tables($filename, $exclude_tables, $nodata_tables, $type = "sql", $destination = "download", $compression = "none", $mode = "manual", $append_timestamp = FALSE) {
  $filemime = "text/plain";
  $success = FALSE;
  if ($append_timestamp) {
    $filename .= "-" . date($append_timestamp);
  }
  $filename = _backup_migrate_clean_filename($filename);

  // Dump the database.
  $temp_file = _backup_migrate_temp_file();
  switch ($type) {
    case "sql":
      $success = _backup_migrate_get_dump_sql($temp_file, $exclude_tables, $nodata_tables);
      $filename .= ".sql";
      $filemime = 'text/x-sql';
      break;
  }

  // Compress the results.
  if ($success) {
    switch ($compression) {
      case "gzip":
        $temp_gz = _backup_migrate_temp_file('gz');
        if ($success = _backup_migrate_gzip_encode($temp_file, $temp_gz, 9)) {
          $temp_file = $temp_gz;
          $filename .= ".gz";
          $filemime = 'application/x-gzip';
        }
        break;
      case "bzip":
        $temp_bz = _backup_migrate_temp_file('bz');
        if ($success = _backup_migrate_bzip_encode($temp_file, $temp_bz)) {
          $temp_file = $temp_bz;
          $filename .= ".bz";
          $filemime = 'application/x-bzip';
        }
        break;
      case "zip":
        $temp_zip = _backup_migrate_temp_file('zip');
        if ($success = _backup_migrate_zip_encode($temp_file, $temp_zip, $filename)) {
          $temp_file = $temp_zip;
          $filename .= ".zip";
          $filemime = 'application/zip';
        }
        break;
    }
  }

  // Save or download the results.
  if ($success) {
    switch ($destination) {
      case "save":
        _backup_migrate_save_to_disk($temp_file, $filename, $mode);
        break;
      case "download":
        _backup_migrate_send_file_to_download($filename, $filemime, $temp_file);
        break;
    }
  }

  // Delete any temporary files we've created.
  _backup_migrate_temp_file("", TRUE);
}