4

I'm trying to get drush-rsync to exclude files/paths that as specified in my alias definitions.

In /etc/drush/aliases.drushrc.php, I defined

$aliases['site_A'] = array(
    'root'   => '/home/test/site_A',
    'uri'    => 'site_A.loc',
    'path-aliases' => array( '%files' => 'sites/default/files', '%dump' => '/home/test/site_A-dump.sql',),
    'command-specific' => array(
        'sql-sync' => array('no-cache' => TRUE,'structure-tables' => array(
        'custom' => array('cache','cache_filter','cache_menu','cache_page','history','sessions','watchdog'),),),
    ),
    'rsync' => array ('simulate' => '0', 'no-cache' => TRUE, 'mode' => 'rlptDz', 'exclude-paths' => 'BLAH:',
    ),
);
$aliases['site_B'] = array(
    'root'   => '/home/test/site_B', 'uri'    => 'site_B.loc',
    'path-aliases' => array(%files' => 'sites/default/files', '%dump' => '/home/test/site_B-dump.sql',),
    'command-specific' => array(
        'sql-sync' => array('no-cache' => TRUE,'structure-tables' => array(
        'custom' => array('cache','cache_filter','cache_menu','cache_page','history','sessions','watchdog'),),),
    ),
    'rsync' => array ('simulate' => '0', 'no-cache' => TRUE, 'mode' => 'rlptDz', 'exclude-paths' => 'BLAH:',
    ),
);

When I test the rsync step,

drush --debug --simulate rsync @site_A @site_B
    Bootstrap to phase 0. [0.01 sec, 4.41 MB]                            [bootstrap]
    Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 4.67 MB] [bootstrap]
    Loading drushrc "/etc/drush/drushrc.php" into "system" scope. [0.02 sec, 4.68 MB]                         [bootstrap]
    Cache HIT cid: 5.0-dev-commandfiles-0-f008e6f6337e0f66b073976a381b26a6 [0.03 sec, 4.69 MB]                    [debug]
    Bootstrap to phase 0. [0.12 sec, 9.76 MB]                                                                 [bootstrap]
    Bootstrap to phase 0. [0.14 sec, 9.76 MB]                                                                 [bootstrap]
    Found command: core-rsync (commandfile=core) [0.15 sec, 9.76 MB]                                          [bootstrap]
    Including /usr/local/drush/commands/core/rsync.core.inc [0.19 sec, 9.77 MB]                        [bootstrap]
    Load alias @site_A [0.2 sec, 9.87 MB]                                                                       [notice]
    Load alias @site_B [0.34 sec, 9.89 MB]                                                                    [notice]
    Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="settings.php" --stats --progress /home/test/site_A// /home/test/site_B/);
    Command dispatch complete [0.75 sec, 10.05 MB]                                                               [notice]
    Peak memory usage was 11.42 MB [0.75 sec, 10.05 MB]                                                          [memory]

I don't see the exclusion of 'BLAH' anywhere.

How do I exclude using the config files, not just on the command line?


EDIT #1

I'd followed this example, http://emspace.com.au/article/drush-aliases-primer-live-dev-syncing, and miscounted nesting levels :-/

Fixing my aliases defs to,

$aliases['site_A'] = array(
    'root'   => '/home/test/site_A', 'uri' => 'site_A.loc',
    'path-aliases' => array( '%files' => 'sites/default/files', '%dump' => '/home/test/site_A-dump.sql',),
    'command-specific' => array(
        'sql-sync' => array(
            'no-cache' => TRUE,
            'structure-tables' => array(
                'custom' => array('cache','cache_filter','cache_menu','cache_page','history','sessions','watchdog'),
            ),
        ),
        'rsync' => array (
            'no-cache' => TRUE,
            'mode' => 'rlptDz',
            'exclude-paths' => 'BLAH:',
        ),
    ),
);
$aliases['site_B'] = array(
    'root'   => '/home/test/site_B', 'uri' => 'site_B.loc',
    'path-aliases' => array(%files' => 'sites/default/files', '%dump' => '/home/test/site_B-dump.sql',),
    'command-specific' => array(
        'sql-sync' => array(
            'no-cache' => TRUE,
            'structure-tables' => array(
                'custom' => array('cache','cache_filter','cache_menu','cache_page','history','sessions','watchdog'),
            ),
        ),
        'rsync' => array (
            'no-cache' => TRUE,
            'mode' => 'rlptDz',
            'exclude-paths' => 'BLAH:',
        ),
    ),
);

and re-executing the 'drush rsync' command,

drush --debug --simulate rsync @site_A @site_B
    Bootstrap to phase 0. [0.01 sec, 4.41 MB]                            [bootstrap]
    Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 4.67 MB] [bootstrap]
    Loading drushrc "/etc/drush/drushrc.php" into "system" scope. [0.02 sec, 4.68 MB]                         [bootstrap]
    Cache HIT cid: 5.0-dev-commandfiles-0-f008e6f6337e0f66b073976a381b26a6 [0.04 sec, 4.69 MB]                    [debug]
    Bootstrap to phase 0. [0.12 sec, 9.76 MB]                                                                 [bootstrap]
    Bootstrap to phase 0. [0.14 sec, 9.76 MB]                                                                 [bootstrap]
    Found command: core-rsync (commandfile=core) [0.14 sec, 9.76 MB]                                          [bootstrap]
    Including /usr/local/drush/commands/core/rsync.core.inc [0.19 sec, 9.78 MB]                        [bootstrap]
    Load alias @site_A [0.19 sec, 9.88 MB]                                                                      [notice]
    Load alias @site_B [0.33 sec, 9.89 MB]                                                                    [notice]
    Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="settings.php" --stats --progress --no-cache /home/test/site_A// /home/test/site_B/);
    Command dispatch complete [0.73 sec, 10.05 MB]                                                               [notice]
    Peak memory usage was 11.42 MB [0.73 sec, 10.05 MB]

there's no 'BLAH' to be seen in the exclusion list.

Removing "--simulate" just in case (how, then do we 'trial run' rsync, if we aren't to use "--simulate" with it anymore?), the sync works, but the same issue -- no 'BLAH' in the exlcusion list,

drush --debug rsync @site_A @site_B
    Bootstrap to phase 0. [0.01 sec, 4.41 MB]                            [bootstrap]
    Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 4.67 MB] [bootstrap]
    Loading drushrc "/etc/drush/drushrc.php" into "system" scope. [0.02 sec, 4.68 MB]                         [bootstrap]
    Cache HIT cid: 5.0-dev-commandfiles-0-f008e6f6337e0f66b073976a381b26a6 [0.04 sec, 4.69 MB]                    [debug]
    Bootstrap to phase 0. [0.13 sec, 9.76 MB]                                                                 [bootstrap]
    Bootstrap to phase 0. [0.15 sec, 9.76 MB]                                                                 [bootstrap]
    Found command: core-rsync (commandfile=core) [0.16 sec, 9.76 MB]                                          [bootstrap]
    Including /usr/local/drush/commands/core/rsync.core.inc [0.2 sec, 9.77 MB]                         [bootstrap]
    Load alias @site_A [0.21 sec, 9.87 MB]                                                                      [notice]
    Load alias @site_B [0.35 sec, 9.89 MB]                                                                    [notice]
    You will destroy data from /home/test/site_B/ and replace with data from /home/test/site_A//
    Do you really want to continue? (y/n): y
    Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="settings.php" --stats --progress /home/test/site_A// /home/test/site_B/);
    sending incremental file list
    ./
    sites/default/
    sites/default/files/ctools/
    sites/default/files/ctools/css/

    Number of files: 4118
    Number of files transferred: 0
    Total file size: 29639208 bytes
    Total transferred file size: 0 bytes
    Literal data: 0 bytes
    Matched data: 0 bytes
    File list size: 83532
    File list generation time: 0.004 seconds
    File list transfer time: 0.000 seconds
    Total bytes sent: 94536
    Total bytes received: 11003

    sent 94536 bytes  received 11003 bytes  70359.33 bytes/sec
    total size is 29639208  speedup is 280.84
    Command dispatch complete [3.21 sec, 10.05 MB]                                                               [notice]
    Peak memory usage was 11.43 MB [3.21 sec, 10.05 MB]                                                          [memory]
5

You accidentally placed your rsync command-specific options outside of the 'command-specific' array.

I don't think that Drush global options (e.g. 'simulate') are supported for commands such as rsync that use strict option handling. Remove 'simulate' if it causes problems in command-specific options.

Edit for comment #4, below:

Here is my modified alias:

$aliases['dev'] = array (
  'root' => '/srv/www/wherever',
  'uri' => 'wherever.net',
    'command-specific' => array(
        'sql-sync' => array(
            'no-cache' => TRUE,
            'structure-tables-list' => array('cache','cache_filter','cache_menu','cache_page','history','sessions','watchdog'),
        ),
        'rsync' => array (
            'no-cache' => TRUE,
            'mode' => 'rlptDz',
            'exclude-paths' => 'BLAH:',
        ),
    ), 
);

Here is the command that uses it:

$ drush -s rsync @live @dev 
Calling system(rsync -e 'ssh ' -rlptDz --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="BLAH" --exclude="settings.php" --rsync-version=2.6.8 --no-cache=1 wwwadmin@10.10.10.10:/srv/www/wherever/ /srv/www/wherever/);

There's an --exclude="BLAH" in there, and I can't see anything that I'm doing differently than you are. Good luck with tracking down your problem.

  • Please see "Edit #1" ^^^ – user6023 Mar 7 '12 at 20:17
  • Regarding 'simulate', my advice was to remove it from your rsync command specific options. Using it as a commandline option is fine. As for your problem with 'exclude-paths', you did not specify your version of Drush, but I am guessing that you are using Drush-4.x. Try with Drush-5.x, which has many improvements and bugfixes, some specifically in rsync. Finally, you did not ask about your sql-sync command specific options, but you should use 'structure-tables-list' => array('cache', ...). The way you have it, you'd also need a 'structure-tables-key' => 'common' for it to work. – greg_1_anderson Mar 7 '12 at 21:00
  • P.S. I did try your exact rsync command specific options on HEAD of Drush-5, and it works fine. – greg_1_anderson Mar 7 '12 at 21:01
  • Thanks for clearing up the "--simulate" (non)usage. My version of Drush is: drush --version --> drush version 5.0-dev; git log | head -n 1 -> commit 59df5221dd46d54c3a7137d64fc0a567a7299231. Re: sql-sync, thanks. Just haven't gotten there yet. But it's noted. p.s. Just re-tried what I posted above, and still no 'BLAH' recognized & apparent in the command output. – user6023 Mar 7 '12 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy