Index: examples/example.drushrc.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/examples/example.drushrc.php,v retrieving revision 1.3 diff -u -p -r1.3 example.drushrc.php --- examples/example.drushrc.php 28 Mar 2010 05:11:48 -0000 1.3 +++ examples/example.drushrc.php 30 Mar 2010 12:33:14 -0000 @@ -77,6 +77,12 @@ // and *.aliases.drushrc.php files # $options['alias-path'] = '/path/to/aliases:/path2/to/more/aliases'; +// Specify directory where sql-sync will store persistent dump files. +// Keeping the dump files around will improve the performance of rsync +// when the database is rsync'ed to a remote system. If a dump directory +// is not specified, then sql-sync will store dumps in temporary files. +# $options['dump-dir'] = '/path/to/dumpdir'; + // Enable verbose mode. # $options['v'] = 1; Index: commands/sql/sql.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/sql/sql.drush.inc,v retrieving revision 1.41 diff -u -p -r1.41 sql.drush.inc --- commands/sql/sql.drush.inc 26 Mar 2010 18:52:04 -0000 1.41 +++ commands/sql/sql.drush.inc 30 Mar 2010 12:33:15 -0000 @@ -111,6 +111,7 @@ function sql_drush_command() { '--target-remote-host' => '', '--target-dump' => '', '--temp' => 'Use a temporary file to hold dump files. Implies --no-cache.', + '--dump-dir' => 'Directory to store sql dump files in when --source-dump or --target-dump are not used. Takes precidence over --temp.', '--create-db' => 'Create a new database before importing the database dump on the target machine.', '--db-su' => 'Account to use when creating a new database. Optional.', '--db-su-pw' => 'Password for the "db-su" account. Optional.', @@ -465,9 +466,35 @@ function _drush_sql_get_spec_from_option return $db_spec; } -function drush_sql_dump_file($db_spec) { - $dump_file = drush_tempnam($db_spec['database'] . '.sql.'); - $db_spec['dump-is-temp'] = TRUE; +/** + * 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. + * + * @param db_spec + * Information about the database being dumped; used + * to generate the filename. + * @return string + * The path to the dump file + */ +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; }