function drush_sql_dump_file

6.x drush_sql_dump_file(&$site_record)
3.x drush_sql_dump_file(&$db_spec)
4.x drush_sql_dump_file(&$db_spec, $prefix)
5.x drush_sql_dump_file(&$site_record)

Determine where to store an sql dump file. This function is called by sql-sync if the caller did not explicitly specify a dump file to use.


db_spec: Information about the database being dumped; used to generate the filename.

Return value

string The path to the dump file

1 call to drush_sql_dump_file()
_drush_sql_sync in commands/sql/


commands/sql/, line 485
Drush sql commands


function drush_sql_dump_file(&$db_spec) {
  // Make a base filename pattern to use to name the dump file
  $filename_pattern = $db_spec['database'];
  if (isset($db_spec['remote-host'])) {
    $filename_pattern = $db_spec['remote-host'] . '_' . $filename_pattern;
  // If the user has set the --dump-dir option, then
  // store persistant sql dump files there.
  $dump_dir = drush_get_option(array('source-dump-dir', 'dump-dir'));
  if (isset($dump_dir)) {
    $dump_file = $dump_dir . '/' . $filename_pattern . '.sql';
  // If the --dump-dir option is not set, then store
  // the sql dump in a temporary file.
  else {
    $dump_file = drush_tempnam($filename_pattern . '.sql.');
    $db_spec['dump-is-temp'] = TRUE;

  return $dump_file;