public function SqlBase::dumpFile

8.0.x SqlBase.php public SqlBase::dumpFile($file)
7.x SqlBase.php public SqlBase::dumpFile($file)
master SqlBase.php public SqlBase::dumpFile($file)
1 call to SqlBase::dumpFile()
SqlBase::dump in lib/Drush/Sql/SqlBase.php

File

lib/Drush/Sql/SqlBase.php, line 104

Namespace

Drush\Sql

Class

SqlBase

Code

public function dumpFile($file) {
  $database = $this->db_spec['database'];

  // $file is passed in to us usually via --result-file.  If the user
  // has set $options['result-file'] = TRUE, then we
  // will generate an SQL dump file in the same backup
  // directory that pm-updatecode uses.
  if ($file) {
    if ($file === TRUE) {
      // User did not pass a specific value for --result-file. Make one.
      $backup = drush_include_engine('version_control', 'backup');
      $backup_dir = $backup->prepare_backup_dir($database);
      if (empty($backup_dir)) {
        $backup_dir = drush_find_tmp();
      }
      $file = $backup_dir . '/@DATABASE_@DATE.sql';
    }
    $file = str_replace(array('@DATABASE', '@DATE'), array($database, gmdate('Ymd_His')), $file);
  }
  return $file;
}