• rsync报错:rsync: chgrp ".hejian.txt.D1juHb" (in backup) failed: Operation not permitted (1)


    问题背景:在配置好rsync服务和客户端后,客户端从服务端拉取是正常的,但从客户端推送到服务端报错。
    a,单独推送目录会报这个错误
    rsync: recv_generator: mkdir "opt" (in backup) failed: Permission denied (13)

    [root@nfs01:/opt]# rsync -avz /opt rsync_backup@10.0.0.41::backup
    Password:
    sending incremental file list
    rsync: recv_generator: mkdir "opt" (in backup) failed: Permission denied (13)
    *** Skipping any contents from this failed directory ***
    opt/
    
    sent 472 bytes  received 172 bytes  257.60 bytes/sec
    total size is 697,812  speedup is 1,083.56
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
    

    如果从客户端向服务端推送目录和文件也报错rsync: chgrp ".backup.sh.RwFAWn" (in backup) failed: Operation not permitted (1)。但文件传过去了,目录并没有传过去

    [root@nfs01:/opt]# rsync -avz /opt/ rsync_backup@10.0.0.41::backup
    Password:
    sending incremental file list
    ./
    backup.sh
    hejian.txt
    services
    rsync: chgrp ".backup.sh.RwFAWn" (in backup) failed: Operation not permitted (1)
    rsync: chgrp ".hejian.txt.iLqEOb" (in backup) failed: Operation not permitted (1)
    rsync: chgrp ".services.vxwJGZ" (in backup) failed: Operation not permitted (1)
    
    sent 136,811 bytes  received 340 bytes  21,100.15 bytes/sec
    total size is 697,812  speedup is 5.09
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
    

    然后检查/backup目录的权限被修改成了550,原来设置的是755,然后把权限修改成755后再重新操作

    [root@backup:/backup]# ls -ld /backup/
    dr-xr-x--- 3 rsync rsync 312 Sep  1 07:54 /backup/
    root@backup:/backup]# chmod 755 /backup/
    [root@backup:/backup]# ls -ld /backup/
    drwxr-xr-x 4 rsync rsync 324 Sep  1 08:03 /backup/
    

    但修改完后再通过客户端同步,还是报上面的错,并且刚修改的目录权限又变成了550

    从网上查询的说是selinux影响,但我检查两台服务器的selinux设置的都是disabled,防火墙也处于关闭状态

    [root@backup:/backup]# getenforce
    Disabled
    

    经排查是由于-a参数导致的,因为-a是归档模式传输,并保持所有文件属性,等价于-rtopgDl(还没有具体深入研究),可以使用下面这个命令替代

    [root@nfs01:/opt]# rsync -rltDvz /opt/ rsync_backup@10.0.0.41::backup
    

    如果还想使用-avz这个参数组合的话,可以在rsyncd.conf配置文件中添加一个参数fake super = yes也能解决问题
    ,同样的命令和配置文件rsync在CentOS6系统之前是不需要的,CentOS7系统需要增加这个参数才不会报错

  • 相关阅读:
    18文件权限管理
    17用户身份管理
    16Shell脚本—计划任务服务程序
    15Shell脚本—流程控制
    14Shell脚本—判断语句
    13Shell脚本—编写简单脚本
    12Vim在系统配置中的应用示例
    11Vim文本编辑器
    10重要的环境变量
    09命令行通配符和转义字符
  • 原文地址:https://www.cnblogs.com/hejian2836/p/11441383.html
Copyright © 2020-2023  润新知