linux - rsync only 文件夹,里面没有文件,也没有扫描文件
问题描述
我想使用 rsync 仅在文件夹 a 和 b 之间同步文件夹
> rsync -zaSH --delete -vv --delete -f"+ f/" -f"- f/*" a/ b
sending incremental file list
[sender] showing directory f because of pattern f/
[sender] hiding file f/1.data because of pattern f/*
[sender] hiding file f/4.data because of pattern f/*
[sender] hiding file f/8.data because of pattern f/*
[sender] hiding file f/10.data because of pattern f/*
[sender] hiding file f/6.data because of pattern f/*
[sender] hiding file f/3.data because of pattern f/*
[sender] hiding file f/5.data because of pattern f/*
[sender] hiding file f/9.data because of pattern f/*
[sender] hiding file f/7.data because of pattern f/*
[sender] hiding file f/2.data because of pattern f/*
delta-transmission disabled for local transfer or --whole-file
f/
total: matches=0 hash_hits=0 false_alarms=0 data=0
sent 88 bytes received 90 bytes 356.00 bytes/sec
total size is 0 speedup is 0.00
> tree
.
├── a
│ └── f
│ ├── 10.data
│ ├── 1.data
│ ├── 2.data
│ ├── 3.data
│ ├── 4.data
│ ├── 5.data
│ ├── 6.data
│ ├── 7.data
│ ├── 8.data
│ └── 9.data
└── b
└── f
从详细输出中可以看出,文件仍然被扫描。如果文件夹中有数百万个文件可能需要很长时间。有没有办法在不扫描文件的情况下实现相同的目标?谢谢。
解决方案
你不能停止它直接扫描里面的文件a/f/
,但它不应该扫描这些文件的任何子目录,除非它们也被调用f
。
此命令也将排除那些:
rsync -aSH --delete -vv --delete -f"+ /f/" -f"- /f/*" a/ b/
带有前缀的模式与/
源目录的根匹配。
(我也删除了-z
,因为压缩对本地副本没有意义。)
推荐阅读
- php - SQL注入:带/不带数组的值
- rest - 在 BigCommerce 中获得所有退款
- c# - 在 Entity Framework 中修改同一个实体是否会同步将实体保存到数据库中?抛出异常?
- c - 初始化使指针在编译时从整数而不进行强制转换
- kubernetes - 从 kubernetes-master 中删除 kube-apiserver(仅用于测试和理解)
- linux - 显示磁盘使用百分比的差异
- cassandra - 如何初始化多节点 Cassandra 集群?
- typescript - 使用泛型类型重载 TypeScript 函数
- javascript - 可排序 - 更新现有数组 - jQuery
- android - dlsym() 返回一个未定义的符号