#!/usr/bin/env bash
# yum install -y inotify-tools rsync xinetd
# ------ /etc/rsyncd.conf -------
# uid=root
# gid=root
# use chroot=no
# max connections=10
# timeout=600
# strict modes=yes
# port=873
# pid file=/var/run/rsyncd.pid
# lock file=/var/run/rsyncd.lock
# log file=/var/log/rsyncd.log
# [jijin_static]
# path=/var/www/static
# comment=rsync test logs
# auth users=admin
# uid=admin
# gid=admin
# secrets file=/etc/rsyncd.secrets
# read only=no
# list=yes
# hosts allow=10.10.10.10
# ------- /etc/rsyncd.secrets -------
# admin:password
# ------ /etc/rsync_client.pwd --------
# password
# chmod 600 /etc/rsync_client.pwd
# vi /etc/xinetd.d/rsync 將disable = yes 改為 no
rsync_user=admin
rsync_ip=10.10.10.20
pwd_path=/etc/rsync_client.pwd
rsync_module=jin_static
nas_path=/var/abver
# 需要排除的檔案和目錄
# inotify_exclude='(.*/*\.log|.*/*\.swp)$|^/tmp/src/mail/(2014|20.*/.*che.*)'
# inotifywait: --exclude $
# 需要排除的檔案和目錄以列表形式儲存在檔案中,一條一行
# rsync_exclude='/etc/rsyncd.d/rsync_exclude.lst'
# rsync: --exclude-from=$
inotifywait -mrq --timefmt '%y/%m/%d-%h:%m:%s:%s' --format '%t %w %f' -e modify,delete,create,move,attrib $ | \
while read file
do# 將本地目錄同步到遠端主機上
rsync -auvrtzopgp --delete --progress --password-file=$ $ $@$::$
# rsync -auvrtzopgp --delete --password-file=/etc/rsyncd.secrets $@$::$ /var/www/static
done
rsync結合 inotfiy 實現實時備份
rsync簡介 rsync是linux系統下的資料映象備份工具。使用快速增量備份工具remote sync可以遠端同步,支援本地複製,或者與其他ssh rsync主機同步 inotify簡介 inotify 是一種強大的 非同步的檔案系統事件監控機制,通過inotify可以監控檔案系統中新增 刪除,...
Rsync實現Linux Windows檔案同步
linux 為服務端,windows 為客戶端 一,服務端的配置 2,兩台伺服器的ip為 client 192.168.2.128 rsync的client端 server 192.168.2.35 rsync的server端 3 1 rsync的server端的操作 tar zxvf rsync ...
rsync實時備份備份服務搭建和使用指南
一.rsync企業工作場景說明 1.利用定時任務 rsync方式實現資料同步 對於 內部技術人員建立的資料,可以採取定時任務的方式 2.利用實時任務 rsync方式實現資料同步 對於 外部訪問使用者建立的資料,可以採取實時同步的方式 3.推送的方法 rsync rp root 10.0.0.10 o...