inotify-tools+rsync同步
salve端部署
1、安装rsync服务端
yum install rsync -y
2、修改配置文件(vim /etc/rsyncd.conf),192.168.88.0/24是允许同步的网段
#Rsync server
uid = root
gid = root
use chroot = yes
max connections = 20
timeout = 900
pid file =/var/run/rsyncd.pid
lock file =/var/run/rsync.lock
log file = /var/log/rsyncd.log
read only = false
list = false
hosts allow = 192.168.88.0/24
hosts deny = *
auth users = rsync_backup
secrets file =/etc/rsync.password
[www]
path = /data/nginx/conf
comment = conf
3、设置密码(vim /etc/rsync.password(rsync.password默认没有))
rsync_backup:123456
4、设置权限
chmod 600 /etc/rsync.passwordmaster端部署
1、安装rsync客户端
yum install rsync -y
2、设置密码(vim /etc/rsync.password(rsync.password默认没有))
123456
3、设置权限
chmod 600 /etc/rsync.password
4、部署inotify-tools
tar -zxvf inotify-tools-3.20.2.2.tar.gz
make -j 4
make install
5、编写同步脚本inotify_rsync.sh
#!/bin/bash
inotifywait -mrq -e create,move,close_write,attrib,delete,modify --exclude="(.*.swp)|(.*~$)|(.*.swx)" /data/nginx/conf/ | while read file
do
rsync -azP --delete /data/nginx/conf/ rsync_backup@192.168.0.217::conf --password-file=/etc/rsync.password &>/dev/null
done
6、执行
nohup sh inotify_rsync.sh &>/var/log/rsync.log &
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 运维小白
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果

