通过 sshfs 进行 Rsync 会跳过以下划线开头的文件名

Nic*_*lov 5 ubuntu synchronization rsync mac-osx sshfs

我正在尝试将目录树从 OS X (10.11) 同步到 Ubuntu 14.04。虽然大多数文件都可以正常传输,但名称以_(下划线)开头的文件却不能。

这是我使用的命令:

rsync -rtvh --progress ~/Pictures/processed/ ~/mnt/processed/
Run Code Online (Sandbox Code Playgroud)

以及输出的示例:

sending incremental file list
_MG_7425.jpg
      4.66M 100%  169.79MB/s    0:00:00 (xfr#1, to-chk=58/60)
_MG_7427.jpg
      6.59M 100%  103.07MB/s    0:00:00 (xfr#2, to-chk=57/60)
...
rsync: mkstemp "/Users/user/mnt/processed/._MG_7425.jpg.0cAYb3" failed: No such file or directory (2)
rsync: mkstemp "/Users/user/mnt/processed/._MG_7427.jpg.5Gw1vD" failed: No such file or directory (2)

sent 306.24M bytes  received 9.46K bytes  122.50M bytes/sec
total size is 306.17M  speedup is 1.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1249) [sender=3.1.2]
Run Code Online (Sandbox Code Playgroud)

我的rsync是从自制软件安装的,版本信息:

rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, no prealloc, file-flags
Run Code Online (Sandbox Code Playgroud)

使用以下命令安装远程位置sshfs

sshfs -o idmap=user username@hostname:/some/path ~/mnt -o auto_cache,reconnect,defer_permissions,noappledouble
Run Code Online (Sandbox Code Playgroud)

使用命令复制跳过的文件之一cp成功。我尝试添加--iconv=utf-8-mac,utf-8--include '_*'选项,但没有效果。

我究竟做错了什么?

Nic*_*lov 4

事实证明,罪魁祸首就在sshfs旗帜上。noappledouble我用来删除文件的标志实际上.DS_Store干扰了rsync的工作。

来自sshfs 挂载选项文档:

诺苹果双

该选项使 osxfuse 拒绝对 Apple Double ( ._) 文件和.DS_Store文件的所有类型的访问。任何现有文件都将变得明显不存在。将不允许创建符合条件的新文件。

正如它所指出的,该选项还与._名称前缀有关,这正是rsync其临时文件所使用的:

rsync: mkstemp "/Users/user/mnt/processed/._MG_7425.jpg.0cAYb3" failed: No such file or directory (2)
Run Code Online (Sandbox Code Playgroud)

这样,在mkstemp创建临时文件时,sshfs就干扰并阻止了它的创建。

从安装命令中删除noappledouble选项sshfs解决了该问题,并且_*文件已正常传输。

感谢@Halfgaar 为我指明了正确的方向。