大佬教程收集整理的这篇文章主要介绍了inotify和rsync实现实时同步,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
客户端:
[[email protected] ~ 12:02:50]#echo "123" > /etc/rsync.pass 生成密码文件
[[email protected] ~ 15:45:39]#chmod 600 /etc/rsync.pass
[[email protected] ~ 15:45:47]#rsync -avz --password-file=/etc/rsync.pass /data/@H_772_25@ [email protected]::BACkup@H_772_25@ 同步数据
sending incremental file list
./
ERROR: daemon refused to receive directory "lost+found"
*** Skipping any contents from this Failed directory ***
data/
sent 72 bytes received 16 bytes 176.00 bytes/sec
@R_831_10586@l size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see prevIoUs errors) (code 23) at main.c(1039) [sender=3.0.6]
结合inotify+rsync实现同步:
[[email protected] ~ 16:08:40]#yum -y install epel-release
[[email protected] ~ 16:08:57]#yum -y install inotify-tools
[[email protected] ~ 16:11:33]#vim inotify_rsync.sh@H_772_25@br/>#!/bin/bash
SRC=‘/data/‘
DEST=‘[email protected]::backup‘
inotifywait -mrq --timefmt ‘%Y-%m-%d %H:%M‘ --format ‘%T %w %f‘ -e create,delete,moved_to,close_write,attrib ${SRC} |while read DATE TIME DIR FILE;do
FILEPATH=${DIR}${FILE}
rsync -az --delete --password-file=/etc/rsync.pass $SRC $DEST && echo "At ${TIME} on ${DATE},file $FILEPATH was backuped up via rsync" >> /var/log/changelist.log
#注意:因为ext系统文件系统有lost+found文件夹,所有rsync会同步成功,但命令的执行结果是失败的,所有不会写日志至/var/log/changelist.log中,要想成功,在ext系统文件系统中把&&换成||即可
done
[[email protected] ~ 16:13:53]#./inotify_rsync.sh
以上是大佬教程为你收集整理的inotify和rsync实现实时同步全部内容,希望文章能够帮你解决inotify和rsync实现实时同步所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。