rsync 统计文件数

mt2*_*t22 8 linux backup file-management rsync command-line

我正在使用带有-vrlHh --delete --stats --force选项的rsync来镜像两个目录。第一个目录是源,它是我的外部高清,目标目录是空的,因为我刚刚创建了它。

我运行rsync -vrlHh --delete --stats --force my_hd dest_dir并得到这个输出。

...

2012/05/12 11:59:29 [18094] Number of files: 189315
2012/05/12 11:59:29 [18094] Number of files transferred: 178767
2012/05/12 11:59:29 [18094] Total file size: 241.57G bytes
2012/05/12 11:59:29 [18094] Total transferred file size: 241.57G bytes
2012/05/12 11:59:29 [18094] Literal data: 241.57G bytes
2012/05/12 11:59:29 [18094] Matched data: 0 bytes
2012/05/12 11:59:29 [18094] File list size: 4.08M
2012/05/12 11:59:29 [18094] File list generation time: 0.002 seconds
2012/05/12 11:59:29 [18094] File list transfer time: 0.000 seconds
2012/05/12 11:59:29 [18094] Total bytes sent: 241.61G
2012/05/12 11:59:29 [18094] Total bytes received: 3.44M
2012/05/12 11:59:29 [18094] sent 241.61G bytes  received 3.44M bytes  30.67M bytes/sec
2012/05/12 11:59:29 [18094] total size is 241.57G  speedup is 1.00
Run Code Online (Sandbox Code Playgroud)

我的问题是Number of filesNumber of file transferred如果目标目录为空,为什么和不同?

Dan*_*son 12

我相信您正在经历http://lists.samba.org/archive/rsync/2008-April/020692.html

简而言之,rsync根据上下文以不同的方式使用“文件”一词。在您的第一个“文件数”计数中,它计算所有内容。在您的第二个“传输的文件数”中,它不将符号链接和目录计为文件。

例子:

$ mkdir test
$ touch test/testfile
$ ln -s testfile test/testlink
$ ls -FR test
test:
testfile  testlink@
$ rsync -vrlHh --stats test test2
sending incremental file list
created directory test2
test/
test/testfile
test/testlink -> testfile

Number of files: 3
Number of files transferred: 1
Total file size: 8 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 67
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 126
Total bytes received: 38

sent 126 bytes  received 38 bytes  328.00 bytes/sec
total size is 8  speedup is 0.05
$ ls -FR test2
test2:
test/

test2/test:
testfile  testlink@
Run Code Online (Sandbox Code Playgroud)