我想知道如何使用rsync对递归的文件夹进行同步,但我只需要更新新文件或已更新的文件(仅更新内容,而不是所有者、组或时间戳),并且希望删除源中不存在的文件。
发布于 2016-03-24 01:00:41
我想你要找的是选择
rsync -r --size-only从手册页:
--size-only
This modifies rsync’s "quick check" algorithm for finding files
that need to be transferred, changing it from the default of
transferring files with either a changed size or a changed
last-modified time to just looking for files that have changed in
size. This is useful when starting to use rsync after using another
mirroring system which may not preserve timestamps exactly.如果确实希望删除源dir中缺少的文件,请使用--delete。
发布于 2016-08-16 06:57:33
您可以强制rsync忽略基于文件模式、时间和大小的检查,并使用基于chksum的方法和"-c“开关。
-c, --checksum skip based on checksum, not mod-time & size这确实意味着,无论文件时间和大小是否匹配,它都需要以块的形式比较整个文件(并在源和目标之间来回传输相关元数据),但只会传输源和目的地之间不同的块。
与其他人建议的其他开关一起使用该开关应该限制复制的内容(只复制已更改的开关),并且可以在源和目标之间进行一致性检查,但这需要更长的时间,这取决于您的链接速度,因为它必须对两侧的文件块进行压缩和比较。
发布于 2020-06-07 13:48:05
最后我用了:
rsync -rv --size-only /mnt/from/ /mnt/to/我的目的地是一个webdav挂载,这使得进程可见,初始文件检查速度快得多。
这不会删除目标中的内容,因为我并没有为我的用例寻找该选项。
https://unix.stackexchange.com/questions/102211
复制相似问题