sql-sync does not read the dump-dir option from drushrc.php

The following commands illustrate the problem:
$ cd /path/to/drupal/root && drush sql-sync @remote
- OR -
$ cd /path/to/drupal/root && drush sql-sync @remote @self

When these commands are executed, drush sql-sync does not read the 'dump-dir' option from drushrc.php.
The following line in drushrc.php has no effect, although example.drushrc.php states that it should work with sql-sync.
$options['dump-dir'] = '/path/to/dump/dir';

Current work-around is to define a site-alias for the site installed at /path/to/drupal/root, with the path-aliases set.

CommentFileSizeAuthor
#3 1730758.patch408 bytesBevan
#2 1730758.patch411 bytesBevan

Comments

greg.1.anderson’s picture

Assigned: Unassigned » greg.1.anderson

As a workaround, try setting $options['source-dump-dir'] and $options['target-dump-dir']. Ideally, $options['dump-dir'] would affect both, so this bug should be fixed.

Bevan’s picture

Title: sql-sync does not read the dump-dir option from drushrc.php » sql-sync ignores dump-dir option in drushrc.php
Version: » 8.x-6.x-dev
Assigned: greg.1.anderson » Unassigned
Status: Active » Needs review
StatusFileSize
new411 bytes

Steps to reproduce

  1. Configure $options['dump-dir'] but not $options['source-dump-dir'] or $options['target-dump-dir'] in global drushrc configuration files. E.g. ~/.drush/drushrc.php.
  2. Configure a remote site alias (E.g. dev) with %dump-dir
  3. cd to a bootstrap-ible drupal site directory.
  4. Run drush sql-sync @dev default.
    • Expected behaviour: If a cached dump is available Drush uses it and informs how to use the --no-cache option. Otherwise Drush immediately notifies that "You will destroy data in %TARGET and replace...".
    • Actual behaviour: Drush does not notice any cached dump in the directory configured by $options['dump-dir'] in drushrc and always notifies of "WARNING: Using temporary files... set '%dump' or '%dump-dir' ..."

The patch

The bug is reproducible on 7.x-5.8, 7.x-5.x and 8.x-6.x. The attached patch applies to and fixes the bug on all those tags/branches. I am not sure if it is best applied to 7.x-5.x or 8.x-6.x?

Bevan’s picture

StatusFileSize
new408 bytes

That patch broke some other uses of drush. This one fixes them. Note that this now fixes the bug for all globally configured paths retrieved via drush_sitealias_get_path_option(), not just 'dump-dir'.

moshe weitzman’s picture

Assigned: Unassigned » greg.1.anderson
greg.1.anderson’s picture

Status: Needs review » Fixed

Committed to 8.x-6.x.

Bevan’s picture

Thanks! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.