该命令应该是您所需要的。rsync
默认情况下使用所谓的快速检查算法:
Rsync查找需要使用“快速检查”算法(默认情况下)的文件,该算法查找大小或上次修改时间已更改的文件。当快速检查指示不需要更新文件的数据时,将直接在目标文件上对其他保留的属性(根据选项的请求)进行任何更改。
在大多数应用程序中,这通常很好。它比为每个文件计算校验和的替代方法更快。第二种方法将保证跟踪差异,第一种方法可能会漏电。
无论如何rsync
,不保留文件的多个副本,这是一个总的文件复印机/同步器,可以根据您提供的选项使一个目录与另一个目录同步。
校验和方法
如果您很好奇,这是我rsync
用来执行这种类型的同步的切换:
$ rsync -avvz -O --stats --checksum --human-readable --acls \
--itemize-changes --progress \
--out-format='[%t] [%i] (Last Modified: %M) (bytes: %-10l) %-100n' \
"SRC" "DEST"
这将生成以下类型的输出:
2014/02/20 09:51:49 INFO sending incremental file list
2014/02/20 09:51:49 INFO delta-transmission disabled for local transfer or --whole-file
2014/02/20 09:51:49 INFO [2014/02/20 09:51:48] [.d..t......] (Last Modified: 2014/02/19-15:51:34) (bytes: 0 ) ./
2014/02/20 09:51:49 INFO [2014/02/20 09:51:48] [>f+++++++++] (Last Modified: 2014/02/19-15:51:33) (bytes: 27981892 ) somefile.zip
27.98M 100% 82.27MB/s 0:00:00 (xfer#1, to-check=0/2) 0
2014/02/20 09:51:49 INFO total: matches=0 hash_hits=0 false_alarms=0 data=27981892
2014/02/20 09:51:49 INFO
2014/02/20 09:51:49 INFO rsync[25205] (sender) heap statistics:
2014/02/20 09:51:49 INFO arena: 1060864 (bytes from sbrk)
2014/02/20 09:51:49 INFO ordblks: 1 (chunks not in use)
2014/02/20 09:51:49 INFO smblks: 4
2014/02/20 09:51:49 INFO hblks: 1 (chunks from mmap)
2014/02/20 09:51:49 INFO hblkhd: 135168 (bytes from mmap)
2014/02/20 09:51:49 INFO allmem: 1196032 (bytes from sbrk + mmap)
2014/02/20 09:51:49 INFO usmblks: 0
2014/02/20 09:51:49 INFO fsmblks: 304
2014/02/20 09:51:49 INFO uordblks: 667008 (bytes used)
2014/02/20 09:51:49 INFO fordblks: 393856 (bytes free)
2014/02/20 09:51:49 INFO keepcost: 393552 (bytes in releasable chunk)
2014/02/20 09:51:49 INFO
2014/02/20 09:51:49 INFO rsync[25207] (server receiver) heap statistics:
2014/02/20 09:51:49 INFO arena: 286720 (bytes from sbrk)
2014/02/20 09:51:49 INFO ordblks: 2 (chunks not in use)
2014/02/20 09:51:49 INFO smblks: 3
2014/02/20 09:51:49 INFO hblks: 3 (chunks from mmap)
2014/02/20 09:51:49 INFO hblkhd: 667648 (bytes from mmap)
2014/02/20 09:51:49 INFO allmem: 954368 (bytes from sbrk + mmap)
2014/02/20 09:51:49 INFO usmblks: 0
2014/02/20 09:51:49 INFO fsmblks: 224
2014/02/20 09:51:49 INFO uordblks: 174480 (bytes used)
2014/02/20 09:51:49 INFO fordblks: 112240 (bytes free)
2014/02/20 09:51:49 INFO keepcost: 102352 (bytes in releasable chunk)
2014/02/20 09:51:49 INFO
2014/02/20 09:51:49 INFO rsync[25206] (server generator) heap statistics:
2014/02/20 09:51:49 INFO arena: 135168 (bytes from sbrk)
2014/02/20 09:51:49 INFO ordblks: 2 (chunks not in use)
2014/02/20 09:51:49 INFO smblks: 6
2014/02/20 09:51:49 INFO hblks: 2 (chunks from mmap)
2014/02/20 09:51:49 INFO hblkhd: 401408 (bytes from mmap)
2014/02/20 09:51:49 INFO allmem: 536576 (bytes from sbrk + mmap)
2014/02/20 09:51:49 INFO usmblks: 0
2014/02/20 09:51:49 INFO fsmblks: 400
2014/02/20 09:51:49 INFO uordblks: 82960 (bytes used)
2014/02/20 09:51:49 INFO fordblks: 52208 (bytes free)
2014/02/20 09:51:49 INFO keepcost: 32816 (bytes in releasable chunk)
2014/02/20 09:51:49 INFO
2014/02/20 09:51:49 INFO Number of files: 2
2014/02/20 09:51:49 INFO Number of files transferred: 1
2014/02/20 09:51:49 INFO Total file size: 27.98M bytes
2014/02/20 09:51:49 INFO Total transferred file size: 27.98M bytes
2014/02/20 09:51:49 INFO Literal data: 27.98M bytes
2014/02/20 09:51:49 INFO Matched data: 0 bytes
2014/02/20 09:51:49 INFO File list size: 93
2014/02/20 09:51:49 INFO File list generation time: 1.277 seconds
2014/02/20 09:51:49 INFO File list transfer time: 0.000 seconds
2014/02/20 09:51:49 INFO Total bytes sent: 27.99M
2014/02/20 09:51:49 INFO Total bytes received: 34
2014/02/20 09:51:49 INFO
2014/02/20 09:51:49 INFO sent 27.99M bytes received 34 bytes 11.20M bytes/sec
2014/02/20 09:51:49 INFO total size is 27.98M speedup is 1.00