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

再次進行實時同步操作,運行腳本

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM