在 Web 服务器环境之间,我们的数据 Assets 文件夹结构类似于以下内容:
/Volumes/data-acct/assets/
├── audio
│ ├── section1
│ │ └── nested files and folders
│ └── section2
├── css
│ ├── section1
│ │ └── nested files and folders
│ └── section2
├── images
│ ├── section1
│ │ └── nested files and folders
│ └── section2
└── videos
├── section1
└── section2
我一直在尝试找到一个包含过滤器,它允许我为每个区域匹配特定的部分文件夹,尽管从 --include="*/"更改时没有得到任何结果
(包含所有文件夹和 --include="*/section1/**/*.*"
rsync --dry-run --verbose --recursive --update --include="*/section1/**/*.*" --exclude="*" /Volumes/data-acct/assets/ /Volumes/data-live/assets/
我应该为此运行多个命令吗?或者我应该使用 --filters 参数(似乎没有记录)
最佳答案
我确信仅使用 rsync 就有一个很好的解决方案(因为它非常强大),但当有疑问时,我喜欢依靠像这样的众所周知的工具:
cd /Volumes/data-acct/assets &&
find . | # get all files
grep /section1/ | # that contain section1
grep -v videos/ | # but without videos
rsync --dry-run --verbose --recursive --update --files-from=- \
/Volumes/data-acct/assets/ /Volumes/data-live/assets/
--files-from 选项允许您创建自己的自定义列表,而无需使用任何 rsync 过滤器。
关于bash - 嵌套的 rsync --include 和 --exclude 规则,是否应该通过多个命令来实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23681752/