function backup_migrate_destination_db::restore_from_file

nittany7 destinations.db.inc backup_migrate_destination_db::restore_from_file($file, &$settings)
mooc7 destinations.db.inc backup_migrate_destination_db::restore_from_file($file, &$settings)

Restore to this source.

File

modules/contrib/backup_migrate/includes/destinations.db.inc, line 163
Functions to handle the direct to database destination.

Class

backup_migrate_destination_db
A destination type for saving to a database server.

Code

function restore_from_file($file, &$settings) {
  $num = 0;
  $type = $this->get_file_type_id();
  // Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
  if ($file->type_id() !== $this->get_file_type_id() && $file->type_id() !== 'sql') {
    _backup_migrate_message("Unable to restore from file %file because a %type file can't be restored to this database.", array("%file" => $file->filepath(), '%type' => $file->type_id()), 'error');
  }
  else {
    backup_migrate_filters_invoke_all('pre_restore', $file, $settings);

    // Restore the database.
    $num = $this->_restore_db_from_file($file, $settings);
    $settings->performed_action = $num ? t('%num SQL commands executed.', array('%num' => $num)) : '';

    backup_migrate_filters_invoke_all('post_restore', $file, $settings, $num);
  }
  return $num;
}