續rsync +inotify

wKiom1MvxwOSlhk-AACJmgiXI1M504.jpg

如圖,內容不解釋,保持服務器

   更正圖:rsyncservice 192.168.56.69                  rsync client 192.168.56.60

●rsync service創建目錄已經用戶並且使用戶無法登錄,授權用戶給共享目錄;

#useradd rsync -s /sbin/nologin -M

#mkdir -p /root/nanwang

#chown -R rsync.rsync /root/nanwang

#echo "rsync_backup:666666" >> /etc/rsync.password

#chmod 600 /etc/rsync.password

●配置rsync服務器

[root@image data]# more /etc/rsyncd.conf
uid = rsync
gid = rsync
use chroot = no
max connections = 99999
timeout = 300
pid file =/var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
[umaildata]
path=/root/data
comment = umailtest
ignore errors
read only = false
list = false
hosts allow = 192.168.56.0/24
hosts deny = *
auth users = rsync_backup
secrets file = /etc/rsync.password

● 輔助服務器爲inotify以及rsync客戶端

配置inotify

下載並且編譯inotify 工具。

 #  tar zxf inotify-tools-3.14.tar.gz

#  cd inotify-tools-3.14

#  ./configure --prefix=/usr/local/  && make && make install

[root@image ~]# more /root/tools/rsyncinotify.sh
   date=date+%F
   /usr/local/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' \
-e close_write /root/nw/ | while read date time dir file;
   do
   rsync -az  /root/nw/ rsync://[email protected]/umaildata --password-file=/etc/rsync.password & >> /dev/null 2>1 \
  echo "At $date file umaildata was backed up via rsync" >> /var/log/rsyncinotify.log
  done



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章