公司如今有一个需求,须要将服务器CentOS的文件定时增量到Windows服务器,Windows服务器链接了存储服务器磁盘阵列,空间比较大。基于这样的需求,咱们采用inotify+rsync增量备份的解决方案。php
IP地址 | 系统 |
---|---|
192.168.1.100 | CentOS7.x |
192.168.1.101 | Windows Server 2012 r2 |
注意:这里的服务器名和密码用于后面配置项目中,默认用户名:SvcCWRSYNC,密码设置为admin123
use chroot = false strict modes = false hosts allow = * log file = rsyncd.log uid = 0 # 须要配置此项,否则链接报错 gid = 0 # 须要配置此项,否则链接报错 # Module definitions # Remember cygwin naming conventions : c:\work becomes /cygwin/c/work # #[test] #path = /cygdrive/c/work #read only = false #transfer logging = yes [rsyncdata] path = /cygdrive/e/cdbid-pro1.0-backup/57 read only = false # 只读属性为false list = no hosts allow = * auth users = SvcCWRSYNC # 对应配置用户名 secrets file = /cygdrive/e/cdbid-pro1.0-backup/rsync.passwd
SvcCWRSYNC:admin123
yum install rsync -y
admin123
chmod 600 /etc/rsync.passwd
inotify-tools工具监测文件增长、删除和修改,同时同步到备份服务器windows
yum install inotify-tools -y
#!/bin/bash host=192.168.1.101 src=/home des=rsyncdata user=SvcCWRSYNC inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files do /usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/rsync.passwd $src $user@$host::$des echo "${files} was rsynced" >>/tmp/rsync.log 2>&1 done
# 测试命令 /usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/rsync.passwd /root/test SvcCWRSYNC@192.168.1.101::rsyncdata
inotify_start.sh &
转载请注明:溜爸 » inotify+rsync将服务器CentOS文件定时增量备份到Windowswindows