You are here

public function backup_migrate_files_destination_archivesource::get_db in Backup and Migrate 7.3

Same name and namespace in other branches
  1. 8.3 includes/sources.archivesource.inc \backup_migrate_files_destination_archivesource::get_db()
  2. 6.3 includes/sources.archivesource.inc \backup_migrate_files_destination_archivesource::get_db()

Gets a database dump to add to the archive.

2 calls to backup_migrate_files_destination_archivesource::get_db()
backup_migrate_files_destination_archivesource::_backup_to_file_cli in includes/sources.archivesource.inc
Backup from this source.
backup_migrate_files_destination_archivesource::_backup_to_file_php in includes/sources.archivesource.inc
Backup from this source.

File

includes/sources.archivesource.inc, line 179
A destination type for saving locally to the server.

Class

backup_migrate_files_destination_archivesource
A destination type for saving locally to the server.

Code

public function get_db() {
  require_once dirname(__FILE__) . '/destinations.inc';
  require_once dirname(__FILE__) . '/files.inc';
  require_once dirname(__FILE__) . '/filters.inc';
  require_once dirname(__FILE__) . '/profiles.inc';
  $file = new backup_file();

  // Clone the default settings so we can make changes without them leaking
  // out of this function.
  $settings = clone _backup_migrate_profile_saved_default_profile();
  $settings->source_id = 'db';
  $settings->filters['compression'] = 'none';

  // Execute the backup on the db with the default settings.
  $file = backup_migrate_filters_backup($file, $settings);

  // Generate a tmp file with the correct final title (because ArchiveTar
  // doesn't seem to allow renaming).
  $tmpdir = backup_migrate_temp_directory();
  $filepath = $tmpdir . '/database.sql';
  rename($file
    ->filepath(), $filepath);
  return $filepath;
}