rsync configuration steps
Server-side
1. Install rsync
Yum Install rsync
2. Modify the configuration file
Vim/etc/rsyncd.conf #默认不存在需要自己创建
##############################
Uid=rsync
Gid=rsync
Use Chroot =no
Max connections=200
timeout=600
PID File=/var/run/rsyncd.pid
Lock file =/var/run/rsyncd.lock
Log file =/var/log/rysncd.log
[ZQ]
Path=/zq
Ignore errors
Read Only=no
List =no
Hosts ALLOW=192.168.1.0/24
Auth USER=ZQ
Secrets file=/etc/web.passwd
3. Create login user and password
Echo zq:123456 >/etc/web.passwd
Client
1. Create a password file
Echo 123456 >/etc/web.passwd
2. Installing Inotify-tools
wget http://120.52.73.47/tenet.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz
Tar XF inotify-tools-3.13.tar.gz
CD inotify-tools-3.13
./configure--prefix=/usr/local/inotify-tools/
Make && make install
3. Create monitoring monitoring and replication scripts
# # # #inotify脚本 # #
#!/bin/sh
Src=/backup
Des=zq
rsync_passwd=/etc/web.passwd
ip=192.168.1.127
User=zq
CD ${SRC}
/usr/local/inotify-tools/bin/inotifywait-mrq--format '%w%f '-e modify,create,delete,attrib,close_write,move./| While Read line
Do
RSYNC-AVZR--timeout--password-file=${rsync_passwd} $line ${user}@${ip}::${des} &>/dev/null
Done
4. Set inotify Script execution permissions:
chmod a+x/rsync.sh
5. Add the script to the boot auto-start file
echo "/root/inotify.sh &" >>/etc/rc.local
Complete
This article is from the "Ops Little Prince" blog, please be sure to keep this source http://superzhangqiang.blog.51cto.com/6399950/1759193
Rsync + inotify Real-time backup