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