加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

rsync – 如何排除一个.htaccess但不是全部.htaccess

发布时间:2020-12-14 02:25:38 所属栏目:Linux 来源:网络整理
导读:我有一个rsync命令用于将我的文件从开发复制到生产.我不想复制 HTML目录根目录中的.htaccess文件,但我想复制其子目录中的几个.htaccess文件. 我正在使用参数–exclude .htaccess来阻止所有文件被复制.我包括的其他参数是-a –recursive –times –perms.是否
我有一个rsync命令用于将我的文件从开发复制到生产.我不想复制 HTML目录根目录中的.htaccess文件,但我想复制其子目录中的几个.htaccess文件.

我正在使用参数–exclude .htaccess来阻止所有文件被复制.我包括的其他参数是-a –recursive –times –perms.是否可以配置rsync来执行此操作?

编辑:
这是我的完整命令:

rsync -a --recursive --times --perms 
    --exclude prop_images --exclude tracking --exclude vtours 
    --exclude .htaccess --exclude .htaccess_backup --exclude "*~"  
    /home/user/dev_html/* /home/user/public_html/

解决方法

指定–exclude .htaccess时,将排除以.htaccess结尾的任何路径.

要仅排除传输源根目录下的.htaccess,您需要–exclude /.htaccess

从rsync手册页,一些更详细的信息和对其他阅读的参考:

  • if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files,otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus “/foo” would match a file named “foo” at either the “root of the transfer” (for a global rule) or in the merge-file’s directory (for a per-directory rule). An unqualified “foo” would match any file or directory named “foo” anywhere in the tree because the algorithm is applied recursively from the top down; it behaves as if each path component gets a turn at being the end of the file name. Even the unanchored “sub/foo” would match at any point in the hierarchy where a “foo” was found within a directory named “sub”. See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify a pattern that matches at the root of the transfer.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读