我正在制作一个脚本,将本地文件夹与来自NAS的远程文件夹同步,该文件夹已使用NAS管理员名称和密码安装到OS X中。
该脚本是:
#!/bin/bash
/usr/bin/sudo /usr/bin/rsync -rav --delete --exclude=".*" /path-to-origin/ /Volumes/NAS/path-to-destination/
该脚本必须由被Auser调用的用户执行,因此我以这种方式从命令行调用脚本:
sudo -u Auser script-to-rsync.sh
我在Terminal收到的回复是:
building file list ... done
./
rsync: chgrp "/Volumes/NAS/path-to-destination/." failed: Operation not permitted (1)
rsync: chgrp "/Volumes/NAS/path-to-destination/file.ext" failed: Operation not permitted (1)
rsync: chgrp "/Volumes/NAS/path-to-destination/." failed: Operation not permitted (1)
sent 311 bytes  received 62 bytes  746.00 bytes/sec
total size is 53864490174  speedup is 144408820.84
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/main.c(992) [sender=2.6.9]
我确定这是一个权限问题,所以我试图将目标文件夹的所有者更改为Auser未成功:
sudo chown fmserver /Volumes/NAS/path-to-destination/
我得到:
chown: /Volumes/ombacap/om15/copies/: Operation not permitted
          
                  您使用的是哪个版本的macOS?
                
                
                  
                    —
                    tubedogg 2016年
                    
                  
                
              
                  @tubedogg El Capitan
                
                
                  
                    —
                    naio 
                    
                  
                
              
                  您的NAS是否提供rsync服务?NAS拥有自己的操作系统,可与其他计算机共享文件。您不能
                
                  
                    —
                    fd0 2016年
                    
                  
                
              chown或chmod从连接的计算机,除非NAS允许您。