Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
#1471254: drush rsync's "--simulate" fails, reports as "unknown option" was submitted and closed since the simulate option now needs to be specified before the rsync command. However, using the 'command-option' in an alias to define the simulate option for the rsync command now breaks. This approach is described in #854722-3: Protecting a site from having it's database overwritten.. How can we accomplish this functionality with Drush 5.x?
My @prod alias (see attached for both aliases):
$aliases['prod'] = array(
'uri' => 'www.test.org',
'root' => '/home/testorg/domains/www.test.org',
'remote-host' => 'test.org',
'remote-user' => 'testorg',
'path-aliases' => array(
'%files' => 'sites/default/files',
'%dump' => '/home/testorg/tmp/sql-sync-prod.sql',
),
'command-specific' => array (
'sql-sync' => array (
'simulate' => '1',
),
'rsync' => array (
'simulate' => '1',
),
),
);
Snippet of output from drush (see attached for full commands and output):
Calling system(rsync -e 'ssh ' -rlptDzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --simulate=1 testorg@test.org:/home/testorg/domains/www.test.org/sites/default/files/ /srv/www/sites/default/files);
rsync: --simulate=1: unknown option
rsync error: syntax or usage error (code 1) at main.c(1443) [client=3.0.7]
Could not rsync from testorg@test.org:/home/testorg/domains/www.test.org/sites/default/files/ to /srv/www/sites/default/files [2.64 [error]
sec, 9.03 MB]
Comment | File | Size | Author |
---|---|---|---|
#2 | command-specific-strict-options.patch | 2 KB | greg.1.anderson |
drush_output.txt | 2.91 KB | dkingofpa | |
aliases.drushrc.php_.txt | 981 bytes | dkingofpa |
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedI think that the best option for protecting a site from sql-sync would be to use a policy file.
Using global options with command specific is, however, broken; even if --simulate is not the best way to protect a site, it should still be valid to put global options in command-specific records for commands such as rsync that use strict option handling, so this bug should be addressed.
Comment #2
greg.1.anderson CreditAttribution: greg.1.anderson commentedHere, try this patch. This allows command specific global options iff said global option is cached in a context. Unsupported global options are silently ignored. Perhaps not ideal. Maybe we should at least throw an error if !array_key_exists('context', $global_options[$key]);
Comment #3
dkingofpa CreditAttribution: dkingofpa commentedI applied the patch in #2 to my drush 5.1 install. That worked for my simulate flag needs with rsync. I didn't try it with any other global options.
But I like your policy suggestion better. I think I'll head down that path.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedSounds like RTBC
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedCommitted with the addition of a drush_log(..., 'warning') if someone tries to use an unsupported command-specific global option with a command that uses strict option handling.