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

Posted hejian2836

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rsync报错:rsync: chgrp ".hejian.txt.D1juHb" (in backup) failed: Operation not permitted相关的知识,希望对你有一定的参考价值。

问题背景:在配置好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系统需要增加这个参数才不会报错

以上是关于rsync报错:rsync: chgrp ".hejian.txt.D1juHb" (in backup) failed: Operation not permitted的主要内容,如果未能解决你的问题,请参考以下文章

使用 rsync 出错:rsync: chgrp "XXXX" failed: Operation not permitted

rsync: chgrp "." (in backup) failed:Operation not

配置 rsync 报错

rsync工具报错

rsync报错rsync: failed to set times on "." (in backup): Permission denied (13)

rsync同步报错