rsync实时同步报错rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]

inotify+rsync 实时同步报错

一、报错信息

能够正常同步,但是会出现下面的报错信息:

[root@192 opt]# ./inotify.sh
rsync: failed to set times on "/." (in wwwroot): Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]

脚本文件如下:

[root@192 opt]# vim /opt/inotify.sh

#!/bin/bash
INOTIFY_CMD="inotifywait -mrq -e modify,create,attrib,move,delete /var/www/html/"
RSYNC_CMD="rsync -azH --delete --password-file=/etc/server.pass /var/www/html/ backuper@192.168.229.90::wwwroot/"
$INOTIFY_CMD | while read DIRECTORY EVENT FILE
##while判断是否接收到监控记录
do
    if [ $(pgrep rsync | wc -l) -le 0 ] ; then
        $RSYNC_CMD
    fi
done

二、解决方法

进入rsync服务器的配置文件,将uid和gid改为root即可;

vi /etc/rsyncd.conf 
uid = root
gid = root

重启rsync服务  

kill $(cat /var/run/rsyncd.pid)
rsync --daemon

再次进行实时同步操作,运行脚本

 

posted on 2021-09-25 12:53  笑洋仟  阅读(2341)  评论(0编辑  收藏  举报

levels of contents