4

I tried adding exclude paths and file patterns to my drush alias; it didn't work, but adding the filters with --exclude= in the command works.

drush rsync --exclude=imagecache/* --exclude=ctools/* --exclude=js/* --exclude=tmp/* --exclude=xmlsitemap/* --exclude=*.doc* --exclude=*.DOC* --exclude=*.pdf* --exclude=*.PDF* --exclude=*.ppt* --exclude=*.PPT* --exclude=*.zip --exclude=*.ZIP --exclude=*.xls* --exclude=*.XLS* @sitename.live:%files @sitename.local:%files

(I wanted to create the directories but skip the contents)

I looked at a similar question but I'm not sure what I am doing wrong.

The docs for drush core-rsync explain:

--exclude-paths List of paths to exclude, seperated by : (Unix-based systems) or ; (Windows).

here is what I tried:

$aliases['live'] = array(
  'root' => '/var/www/[domain]/htdocs',
  'uri' => '[site uri]',
  'remote-host' => '[host ip]',
  'remote-user' => 'rgoya',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
  ),
  'command-specific' => array(
        'sql-sync' => array(
            'no-cache' => TRUE,      
        ),
        'rsync' => array (
            'mode' => 'rlptDz',
            'exclude-paths' => 'css:imagecache:ctools:js:tmp::xmlsitemap',
            'exclude' => '*.tmp',
            'exclude' => '*.doc*',
            'exclude' => '*.zip',
            'exclude' => '*.xls*',
        ),
    ), 
);

I also tried 'mode' => 'azv'

Also, can I use regexp in the exclude patterns? some extensions are lowercase, some are uppercase .pdf / .PDF

3 Answers 3

5

Your subsequent 'exclude' items in the PHP array are overwriting their previous ones, so the example above only has --exclude=xls

drush help rsync does not explicitly document the syntax for --exclude but I assume that it's similar to --explude-path and that would mean you should do something like this:

'rsync' => array (
  'mode' => 'rlptDz',
  'exclude-paths' => 'css:imagecache:ctools:js:tmp::xmlsitemap',
  'exclude' => '*.tmp:*.doc*:*.zip:*.xls*',
),

EDIT: looking into the example.aliases.drushrc.php there is this tip included:

// if you need multiple exludes, use an rsync exclude file
'exclude-from' => "'/etc/rsync/exclude.rules'",

That's maybe the best way to go.

0

Drush does not support multiple options with the same key (e.g. --exclude=a --exclude=b) unless the command supports strict options. See drush topic docs-strict-options for more information on strict option handling. Basically, strict options require that gloabl Drush options appear before the command name, and every option after the command name is passed on without being parsed by Drush. This also means that command-specific options cannot include strict options, as only options from the command line are passed on to rsync as a strict option.

You therefore must use 'exclude-paths' in command-specific options if you would like to exclude multiple items in drush rsync.

0

this is what is working now for sql-sync and sql-dump - have not executed drush-rsync again since it's now unnecessary after my original sync, for the time being

$aliases['local'] = array(
'root' => '/var/www/[root dir]',
'uri' => '[uri]',
'path-aliases' => array(
    '%files' => 'sites/default/files',
    '%dump-dir' => '/home/decibelplaces/drush-dumps',
),
'command-specific' => array(
    'sql-sync' => array(
        'no-cache' => TRUE,
        'structure-tables' => array(
            'common' => array(
                'cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog','search_index',[some other custom tables],
            ),     
        ),
    ),
    'sql-dump' => array(
        'structure-tables' => array(
            'common' => array(
                'cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog','search_index',[some other custom tables],
            ),     
        ),
    ),
    'rsync' => array (
        'mode' => 'avzu',
    ),
),

);

with drush syntax:

drush sql-sync @yoursite.remote @yoursite.local --structure-tables-key=common --no-ordered-dump --sanitize=0 --no-cache

also, to save a sql dump in a specified file with a date

drush @yoursite.local sql-dump --structure-tables-key=common --result-file=[path to file result]/local_`date +"%Y_%m_%d-%H:%M"`.sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.