rsyncd_server.conf:
uid = root
gid = root
use chroot = no
max connections = 100
strict modes = yes
pid file = /webserver/logs/rsync.pid
log file = /webserver/logs/rsyncd.log
ignore error = yes
timeout = 300

[data]
path = /data
read only = no
write only = no
hosts allow = *
list = false
uid = root
gid = root
auth users = root
secrets file = /webserver/rsync/rsyncd_server.passwd

[image]
path = /data/res/static/photos
read only = no
write only = no
hosts allow = *
list = false
uid = root
gid = root
auth users = root
secrets file = /webserver/rsync/rsyncd_server.passwd

rsync.sh:
#!/bin/bash
src1=/media
src2=/webserver
rsync_passwd_file=/webserver/rsync/rsyncd_server.passwd

if [ ! -e “$src1” ] || [ ! -e “$src2” ] || [ ! -e “/usr/bin/rsync” ] || [ ! -e “$rsync_passwd_file” ]; then
echo “Check File and Folder”
exit 1
fi
rsync –daemon –config=/webserver/rsync/rsyncd.conf

inotify.sh:
/usr/bin/killall -9 inotifywait
/bin/sleep 2
/usr/bin/killall -9 rsync
/bin/sleep 2
src=/data
des=data
rsync_passwd_file=/home/kandao/workspace/rms/scripts/rsync_copy/rsyncd_client.passwd
ip=portalxxx.kandaoxx.tech
# server auth name
user=root

# check
if [ ! -e “${src}” ] || [ ! -e “/usr/bin/inotifywait” ] || [ ! -e “/usr/bin/rsync” ] || [ ! -e “${rsync_passwd_file}” ]; then
echo “Check File and Folder”
exit 1
fi
# need cd into local path
cd ${src}
/usr/bin/inotifywait -mrq –format ‘%Xe %w%f’ -e modify,create,delete,attrib,close_write,move ./ | while read file
do
INO_EVENT=$(echo $file | awk ‘{print $1}’)
INO_FILE=$(echo $file | awk ‘{print $2}’)
echo “——————————-$(date)————————————”
echo $file
# create,modify,close_write,move to
if [[ $INO_EVENT =~ ‘CREATE’ ]] || [[ $INO_EVENT =~ ‘MODIFY’ ]] || [[ $INO_EVENT =~ ‘CLOSE_WRITE’ ]] || [[ $INO_EVENT =~ ‘MOVED_TO’ ]]
then
echo ‘CREATE or MODIFY or CLOSE_WRITE or MOVED_TO’
rsync -avzctRP –password-file=${rsync_passwd_file} $(dirname ${INO_FILE}) –exclude-from=/data/rsyncexclude.txt ${user}@${ip}::${des}
fi
# delete move from
if [[ $INO_EVENT =~ ‘DELETE’ ]] || [[ $INO_EVENT =~ ‘MOVED_FROM’ ]]
then
echo ‘DELETE or MOVED_FROM’
rsync -avztRP –password-file=${rsync_passwd_file} $(dirname ${INO_FILE}) –exclude-from=/data/rsyncexclude.txt ${user}@${ip}::${des}
fi
# touch chgrp chmod chown
if [[ $INO_EVENT =~ ‘ATTRIB’ ]]
then
echo ‘ATTRIB’
if [ ! -d “$INO_FILE” ]
then
rsync -avzctRP –password-file=${rsync_passwd_file} $(dirname ${INO_FILE}) –exclude-from=/data/rsyncexclude.txt ${user}@${ip}::${des}
fi
fi
done

rsyncd_server.passwd
root:xxxxpassword

rsyncd_client.passwd
xxxxpassword

rsyncexclude.txt
origin
origin/*
_thumbnails
_thumbnails/*
WEBM
WEBM/*
rsyncexclude.txt