首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用排除路径和文件模式为rsync配置drush别名

使用排除路径和文件模式为rsync配置drush别名
EN

Drupal用户
提问于 2014-02-14 01:28:58
回答 3查看 3.9K关注 0票数 4

我尝试将排除路径和文件模式添加到我的drush别名中;它没有工作,但是在命令中添加带有-- with =的过滤器是有效的。

代码语言:javascript
复制
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

(我想创建目录,但跳过目录)

我看了一个相似问题,但我不知道我做错了什么。

钻核-rsync的文档解释如下:

-排除-要排除的路径列表,由:(基于Unix的系统)或;(Windows)分隔。

以下是我尝试过的:

代码语言:javascript
复制
$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*',
        ),
    ), 
);

我也尝试过‘=>’azv模式

另外,我可以在排除模式中使用regexp吗?一些扩展是小写的,有些是大写的.pdf / .PDF

EN

回答 3

Drupal用户

发布于 2014-02-15 10:43:00

PHP数组中的后续“排除”项正在覆盖它们以前的项,因此上面的示例只包含- only =xls。

drush help rsync并没有显式地记录--排除的语法,但我假设它类似于--解释路径,这意味着您应该这样做:

代码语言:javascript
复制
'rsync' => array (
  'mode' => 'rlptDz',
  'exclude-paths' => 'css:imagecache:ctools:js:tmp::xmlsitemap',
  'exclude' => '*.tmp:*.doc*:*.zip:*.xls*',
),

编辑:查看example.aliases.drushrc.php,这里包括以下技巧:

代码语言:javascript
复制
// if you need multiple exludes, use an rsync exclude file
'exclude-from' => "'/etc/rsync/exclude.rules'",

也许这是最好的方法。

票数 5
EN

Drupal用户

发布于 2014-02-15 19:21:03

这就是现在对sql-sync和sql-dump -已不再执行drush-rsync的工作方式,因为在我最初的同步之后,它现在已经没有必要了。

代码语言:javascript
复制
$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',
    ),
),

);

使用drush语法:

代码语言:javascript
复制
drush sql-sync @yoursite.remote @yoursite.local --structure-tables-key=common --no-ordered-dump --sanitize=0 --no-cache

此外,若要将sql转储保存在带有日期的指定文件中,请执行以下操作:

代码语言:javascript
复制
drush @yoursite.local sql-dump --structure-tables-key=common --result-file=[path to file result]/local_`date +"%Y_%m_%d-%H:%M"`.sql
票数 0
EN

Drupal用户

发布于 2014-02-16 18:27:16

除非命令支持严格的选项,否则Drush不支持具有相同键的多个选项(例如-)有关严格选项处理的更多信息,请参见drush topic docs-strict-options。基本上,严格的选项要求gloabl Drush选项出现在命令名之前,而命令名之后的每个选项都不需要Drush解析。这也意味着特定于命令的选项不能包含严格的选项,因为只有来自命令行的选项作为严格选项传递给rsync。

因此,如果要排除drush rsync中的多个项,则必须在命令特定选项中使用“排除-路径”。

票数 0
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/103376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档