rsync+inotify 实现文件夹的自动同步备份

1 配置好rsync 服务器,客户端,见上一篇git

   192.168.1.10web服务器中/www  备份到 rsync192.168.1.11 /tmp/backupgithub

2 下载安装inotifyweb

    wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz vim

    解压 ./configure   make make install
bash

3 简介服务器

    

inotify-tools提供的两个命令行工具:ide

inotifywait:课以进行持续性的监控。工具

inotifywatch:统计信息。spa


4  实现监控上传命令行

    vim /in.sh

#!/bin/bash

inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib /www | while read files

        do

rsync -avz  --delete --password-file=/etc/rsync.password /www  renkun@192.168.1.11::backup


done  

保存


5  后台执行脚本

    nohup /in.sh &(使用程序部署nohup)

6 开机启动

    echo “nohup /in.sh” >>/etc/rc.local

相关文章
相关标签/搜索