当目标为 zfs 时,Rsync 对于以下划线开头的文件失败

当目标为 zfs 时,Rsync 对于以下划线开头的文件失败

我在 Mac OS X 10.8.5 上使用 rsync3.1.0pre1,并尝试将一个文件夹 rsync 到另一个文件夹。目标是通过 SMB 挂载的 ZFS 卷。

我遇到的问题是以下划线开头的文件(例如“_filename.jpg”)无法成功同步到目标。我收到以下错误消息:

rsync: mkstemp "/path/to/destination/._filename.jpg.NUgYJw" failed: Permission denied (13)

在这种情况下,_filename.jpg就无法到达目的地。

我理解 rsync 会在目标位置创建隐藏的临时文件,这些文件前面带有.,末尾附加有随机文件扩展名。但原始文件名以 开头_,而不是._,而且我还没有要求 rsync 复制扩展属性/资源分支(除非它总是这样做)。

我使用的 rsync 命令是:

rsync -av --exclude='.DS_Store' --exclude '.Trash' --exclude 'Thumbs.db' --exclude '._*' --delete /source/ /destination/

有人找到解决这个问题的方法吗?谢谢!

答案1

从原始海报来看,问题修订 3

我们找到了答案(Dave Veffer 找到了)。smb 服务器正在否决._*。只需将其从 smb.conf 中删除即可。我在 OS X 上使用 SMBUp。smb.conf 位于 /opt/local/etc/samba3/smb.conf

答案2

一种解决方法可能是使用 rsync 的--inplace参数,从而避免创建临时文件。不过,它也有自己的注意事项:

--inplace
       This  option  changes how rsync transfers a file when its data needs to be updated: instead of the
       default method of creating a new copy of the file and moving it into place when  it  is  complete,
       rsync instead writes the updated data directly to the destination file.

              This has several effects:

              o      Hard  links  are  not  broken.   This means the new data will be visible through other hard
                     links to the destination file.  Moreover, attempts to copy differing source  files  onto  a
                     multiply-linked  destination  file  will result in a "tug of war" with the destination data
                     changing back and forth.

              o      In-use binaries cannot be updated (either the OS  will  prevent  this  from  happening,  or
                     binaries that attempt to swap-in their data will misbehave or crash).

              o      The  file’s data will be in an inconsistent state during the transfer and will be left that
                     way if the transfer is interrupted or if an update fails.

              o      A file that rsync cannot write to cannot be updated. While a  super  user  can  update  any
                     file,  a  normal  user  needs  to  be granted write permission for the open of the file for
                     writing to be successful.

              o      The efficiency of rsync’s delta-transfer algorithm may be  reduced  if  some  data  in  the
                     destination  file  is  overwritten before it can be copied to a position later in the file.
                     This does not apply if you use --backup, since rsync is smart enough to use the backup file
                     as the basis file for the transfer.

              WARNING:  you  should not use this option to update files that are being accessed by others, so be
              careful when choosing to use this for a copy.

              This option is useful for transferring large files with block-based changes or appended data,  and
              also  on  systems  that  are disk bound, not network bound.  It can also help keep a copy-on-write
              filesystem snapshot from diverging the entire contents of a file that only has minor changes.

              The option implies --partial (since an  interrupted  transfer  does  not  delete  the  file),  but
              conflicts  with  --partial-dir  and  --delay-updates.   Prior  to  rsync  2.6.4 --inplace was also
              incompatible with --compare-dest and --link-dest.

相关内容