rsyncをcronで定期的に実行して、サーバー間のファイル同期する方法でも問題ないが、
ファイル送信元のデータが変更されたら出来るだけ迅速に送信先にもデータが同期されるように
しておきたい場合はGoogleからダウンロード出来るlsyncdを利用してファイル同期するという
選択肢があっても良いかもしれません。

CRONで直接rsyncを実行する場合の例)

rsync -av /home/sync_user/lsync/ sync_user@home002:/home/sync_user/lsync/

システム環境
|– HOME001:/home/sync_user/lsync/ (同期元)
      |– lsyncd_test002:/home/sync_user/lsync/(同期先)

[root@HOME001 sync_user]# uname -r
2.6.32-279.el6.i686
[root@HOME001 sync_user]#

[root@HOME002 lsync]# uname -r
2.6.18-53.1.21.el5
[root@HOME002 lsync]#

同期:ユーザーsync_user

———————————————-

ファイル同期先サーバーでrsync設定
1) rsyncd.conf作成 2) xinetdをインストールしrsyncを自動起動設定

[root@HOME002 sync_user]# vi /etc/rsyncd.conf
[root@HOME002 sync_user]# cat /etc/rsyncd.conf
[sync_user]
    path = /home/sync_user/lsync
    hosts allow = 192.168.11.0/24
    read only = false
[root@HOME002 sync_user]#

[root@HOME002 sync_user]# rpm -qi xinetd
パッケージ xinetd はインストールされていません。
[root@HOME002 sync_user]# yum -y install xinetd
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for xinetd to pack into transaction set.
xinetd-2.3.14-16.el5.i386 100% |=========================| 8.9 kB    00:00
---> Package xinetd.i386 2:2.3.14-16.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 xinetd                  i386       2:2.3.14-16.el5  base              126 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 126 k
Downloading Packages:
(1/1): xinetd-2.3.14-16.e 100% |=========================| 126 kB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: xinetd                       ######################### [1/1]

Installed: xinetd.i386 2:2.3.14-16.el5
Complete!
[root@HOME002 sync_user]#
[root@HOME002 sync_user]# /etc/rc.d/init.d/xinetd start
xinetd を起動中:                                           [  OK  ]
[root@HOME002 sync_user]# /sbin/chkconfig xinetd on
[root@HOME002 sync_user]# /sbin/chkconfig --list xinetd
xinetd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@HOME002 sync_user]# rpm -qi xinetd
Name        : xinetd                       Relocations: (not relocatable)
Version     : 2.3.14                            Vendor: CentOS
Release     : 16.el5                        Build Date: 2012年02月23日 01時49分52秒
Install Date: 2013年01月07日 14時41分23秒      Build Host: builder10.centos.org
Group       : System Environment/Daemons    Source RPM: xinetd-2.3.14-16.el5.src.rpm
Size        : 263015                           License: xinetd
Signature   : DSA/SHA1, 2012年02月23日 03時54分46秒, Key ID a8a447dce8562897
URL         : http://www.xinetd.org
Summary     : Inetd に代わる安全なデーモン
Description :
インターネットサービスデーモン inetd の代わりに Xinetd を使用しても安全
です。Xinetd はリモートホストのアドレスやアクセスの時刻に基づいてすべ
てのサービスに対するアクセス制御を行います。またアクセス拒否型攻撃を防
御することができます。Xinetd は、豊富なロギング機能を提供
します。サーバー引数の数に制限がなくホストマシン上の特定サービスと特定
IP アドレスをバインドすることができます。各サービスは各々独自の設定
ファイルを持ち、それらは /etc/xinetd.d ディレクトリに置かれます。
[root@HOME002 sync_user]#
[root@HOME002 sync_user]# /sbin/chkconfig rsync on
[root@HOME002 sync_user]# /sbin/chkconfig --list rsync
rsync           on
[root@HOME002 sync_user]#

xinetd

ファイル同期元のサーバーにlsyncdをインストールする為に必要なパッケージインストール
事前インストール:libxml2-devel、lua-devel、lua-static、asciidoc

[root@HOME001 sync_user]# yum -y install libxml2-devel lua-devel lua-static
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
base                                                                               | 3.7 kB     00:00
extras                                                                             | 3.5 kB     00:00
updates                                                                            | 3.5 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.i686 0:2.7.6-8.el6_3.4 will be installed
--> Processing Dependency: libxml2 = 2.7.6-8.el6_3.4 for package: libxml2-devel-2.7.6-8.el6_3.4.i686
---> Package lua-devel.i686 0:5.1.4-4.1.el6 will be installed
---> Package lua-static.i686 0:5.1.4-4.1.el6 will be installed
--> Running transaction check
---> Package libxml2.i686 0:2.7.6-4.el6_2.4 will be updated
--> Processing Dependency: libxml2 = 2.7.6-4.el6_2.4 for package: libxml2-python-2.7.6-4.el6_2.4.i686
---> Package libxml2.i686 0:2.7.6-8.el6_3.4 will be an update
--> Running transaction check
---> Package libxml2-python.i686 0:2.7.6-4.el6_2.4 will be updated
---> Package libxml2-python.i686 0:2.7.6-8.el6_3.4 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================
 Package                       Arch                Version                         Repository              Size
================================================================================================================
Installing:
 libxml2-devel                 i686                2.7.6-8.el6_3.4                 updates                1.1 M
 lua-devel                     i686                5.1.4-4.1.el6                   base                    20 k
 lua-static                    i686                5.1.4-4.1.el6                   base                    89 k
Updating for dependencies:
 libxml2                       i686                2.7.6-8.el6_3.4                 updates                800 k
 libxml2-python                i686                2.7.6-8.el6_3.4                 updates                314 k

Transaction Summary
================================================================================================================
Install       3 Package(s)
Upgrade       2 Package(s)

Total download size: 2.3 M
Downloading Packages:
(1/5): libxml2-2.7.6-8.el6_3.4.i686.rpm                                                  | 800 kB     00:00
(2/5): libxml2-devel-2.7.6-8.el6_3.4.i686.rpm                                            | 1.1 MB     00:00
(3/5): libxml2-python-2.7.6-8.el6_3.4.i686.rpm                                           | 314 kB     00:00
(4/5): lua-devel-5.1.4-4.1.el6.i686.rpm                                                  |  20 kB     00:00
(5/5): lua-static-5.1.4-4.1.el6.i686.rpm                                                 |  89 kB     00:00
----------------------------------------------------------------------------------------------------------------
Total                                                                           2.0 MB/s | 2.3 MB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lua-devel-5.1.4-4.1.el6.i686                                                                 1/7
  Installing : lua-static-5.1.4-4.1.el6.i686                                                                2/7
  Updating   : libxml2-2.7.6-8.el6_3.4.i686                                                                 3/7
  Installing : libxml2-devel-2.7.6-8.el6_3.4.i686                                                           4/7
  Updating   : libxml2-python-2.7.6-8.el6_3.4.i686                                                          5/7
  Cleanup    : libxml2-python-2.7.6-4.el6_2.4.i686                                                          6/7
  Cleanup    : libxml2-2.7.6-4.el6_2.4.i686                                                                 7/7
  Verifying  : libxml2-python-2.7.6-8.el6_3.4.i686                                                          1/7
  Verifying  : libxml2-devel-2.7.6-8.el6_3.4.i686                                                           2/7
  Verifying  : lua-static-5.1.4-4.1.el6.i686                                                                3/7
  Verifying  : libxml2-2.7.6-8.el6_3.4.i686                                                                 4/7
  Verifying  : lua-devel-5.1.4-4.1.el6.i686                                                                 5/7
  Verifying  : libxml2-python-2.7.6-4.el6_2.4.i686                                                          6/7
  Verifying  : libxml2-2.7.6-4.el6_2.4.i686                                                                 7/7

Installed:
  libxml2-devel.i686 0:2.7.6-8.el6_3.4    lua-devel.i686 0:5.1.4-4.1.el6    lua-static.i686 0:5.1.4-4.1.el6

Dependency Updated:
  libxml2.i686 0:2.7.6-8.el6_3.4                      libxml2-python.i686 0:2.7.6-8.el6_3.4

Complete!
[root@HOME001 sync_user]#

[root@HOME001 lsyncd-2.1.4]# yum install asciidoc
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package asciidoc.noarch 0:8.4.5-4.1.el6 will be installed
--> Processing Dependency: docbook-style-xsl for package: asciidoc-8.4.5-4.1.el6.noarch
--> Running transaction check
---> Package docbook-style-xsl.noarch 0:1.75.2-6.el6 will be installed
--> Processing Dependency: docbook-dtd-xml for package: docbook-style-xsl-1.75.2-6.el6.noarch
--> Running transaction check
---> Package docbook-dtds.noarch 0:1.0-51.el6 will be installed
--> Processing Dependency: sgml-common >= 0.6.3-4 for package: docbook-dtds-1.0-51.el6.noarch
--> Running transaction check
---> Package sgml-common.noarch 0:0.6.3-32.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================
 Package                            Arch                    Version                          Repository             Size
=========================================================================================================================
Installing:
 asciidoc                           noarch                  8.4.5-4.1.el6                    base                  183 k
Installing for dependencies:
 docbook-dtds                       noarch                  1.0-51.el6                       base                  274 k
 docbook-style-xsl                  noarch                  1.75.2-6.el6                     base                  2.6 M
 sgml-common                        noarch                  0.6.3-32.el6                     base                   43 k

Transaction Summary
=========================================================================================================================
Install       4 Package(s)

Total download size: 3.1 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): asciidoc-8.4.5-4.1.el6.noarch.rpm                                                          | 183 kB     00:00
(2/4): docbook-dtds-1.0-51.el6.noarch.rpm                                                         | 274 kB     00:00
(3/4): docbook-style-xsl-1.75.2-6.el6.noarch.rpm                                                  | 2.6 MB     00:00
(4/4): sgml-common-0.6.3-32.el6.noarch.rpm                                                        |  43 kB     00:00
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    3.8 MB/s | 3.1 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : sgml-common-0.6.3-32.el6.noarch                                                                       1/4
  Installing : docbook-dtds-1.0-51.el6.noarch                                                                        2/4
  Installing : docbook-style-xsl-1.75.2-6.el6.noarch                                                                 3/4
  Installing : asciidoc-8.4.5-4.1.el6.noarch                                                                                       4/4
  Verifying  : docbook-style-xsl-1.75.2-6.el6.noarch                                                                               1/4
  Verifying  : asciidoc-8.4.5-4.1.el6.noarch                                                                                       2/4
  Verifying  : sgml-common-0.6.3-32.el6.noarch                                                                                     3/4
  Verifying  : docbook-dtds-1.0-51.el6.noarch                                                                                      4/4

Installed:
  asciidoc.noarch 0:8.4.5-4.1.el6

Dependency Installed:
  docbook-dtds.noarch 0:1.0-51.el6          docbook-style-xsl.noarch 0:1.75.2-6.el6          sgml-common.noarch 0:0.6.3-32.el6

Complete!
[root@HOME001 lsyncd-2.1.4]#

同期元サーバーにてlsyncdダウンロードとインストール

[root@HOME001 sync_user]# wget http://lsyncd.googlecode.com/files/lsyncd-2.1.4.tar.gz
--2013-01-07 14:45:25--  http://lsyncd.googlecode.com/files/lsyncd-2.1.4.tar.gz
lsyncd.googlecode.com をDNSに問いあわせています... 74.125.31.82, 2404:6800:4008:c00::52
lsyncd.googlecode.com|74.125.31.82|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 150852 (147K) [application/x-gzip]
`lsyncd-2.1.4.tar.gz' に保存中

100%[===============================================================================>] 150,852      222K/s 時間 0.7s

2013-01-07 14:45:26 (222 KB/s) - `lsyncd-2.1.4.tar.gz' へ保存完了 [150852/150852]

[root@HOME001 sync_user]#

[root@HOME001 sync_user]# tar zxvf lsyncd-2.1.4.tar.gz
lsyncd-2.1.4/
lsyncd-2.1.4/default-rsyncssh.lua
lsyncd-2.1.4/COPYING
lsyncd-2.1.4/doc/
lsyncd-2.1.4/doc/lsyncd.1.txt
lsyncd-2.1.4/doc/lsyncd.1
lsyncd-2.1.4/Makefile.am
lsyncd-2.1.4/default-direct.lua
lsyncd-2.1.4/config.h.in
lsyncd-2.1.4/m4/
lsyncd-2.1.4/m4/ax_subst_l.m4
省略...
lsyncd-2.1.4/examples/limagemagic.lua
lsyncd-2.1.4/examples/lrsync.lua
lsyncd-2.1.4/examples/lrsyncssh.lua
lsyncd-2.1.4/examples/lbash.lua
lsyncd-2.1.4/examples/lgforce.lua
[root@HOME001 sync_user]#

[root@HOME001 lsyncd-2.1.4]# ./configure && make && make install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...

省略...
make[1]: ディレクトリ `/home/sync_user/lsyncd-2.1.4' から出ます
make[1]: ディレクトリ `/home/sync_user/lsyncd-2.1.4' に入ります
 /bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c lsyncd '/usr/local/bin'
 /bin/mkdir -p '/usr/local/share/doc/lsyncd/'
 /usr/bin/install -c -m 644 examples/lbash.lua examples/lecho.lua examples/lgforce.lua examples/limagemagic.lxamples/lrsync.lua examples/lrsyncssh.lua '/usr/local/share/doc/lsyncd/'
 /bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 doc/lsyncd.1 '/usr/local/share/man/man1'
make[1]: ディレクトリ `/home/sync_user/lsyncd-2.1.4' から出ます
[root@HOME001 lsyncd-2.1.4]#

[root@HOME001 lsyncd-2.1.4]# cp examples/lrsync.lua /etc/lsyncd.conf
[root@HOME001 lsyncd-2.1.4]# vi /etc/lsyncd.conf
[root@HOME001 sync_user]# cat /etc/lsyncd.conf
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync.
--
settings  {
        statusFile = "/tmp/lsyncd.stat",
        statusInterval = 1,
        logfile="/var/log/lsyncd.log",
}

sync {
        default.rsync,
        source="/home/sync_user/lsync/",
        target="HOME002:/home/sync_user/lsync/",
--      rsyncOps={"-rv",},
--      rsyncOps={"-ltus",},
--      exclude = "/home/sync_user/lsync/nonsync/"
        exclude={"/nonsync/"},
}

[root@HOME001 sync_user]#

ファイル同期をパスワード入力無しで行う為の設定
ーファイル送信元で作成して送信先の.sshにキーをコピーしておく。
ー同期をsync_userにて行う為に鍵をsync_userになって作成する。

[root@HOME001 sync_user]# su - sync_user
[sync_user@HOME001 ~]$ pwd
/home/sync_user
[sync_user@HOME001 ~]$ ls -l
合計 156
drwxr-xr-x. 2 sync_user sync_user   4096  1月  7 14:23 2013 lsync
drwxr-xr-x. 6 mysql     mysql       4096  1月  7 14:59 2013 lsyncd-2.1.4
-rw-r--r--. 1 root      root      150852 11月 24 22:47 2012 lsyncd-2.1.4.tar.gz
[sync_user@HOME001 ~]$ ssh-keygen -t rsa -N ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sync_user/.ssh/id_rsa):
Created directory '/home/sync_user/.ssh'.
Your identification has been saved in /home/sync_user/.ssh/id_rsa.
Your public key has been saved in /home/sync_user/.ssh/id_rsa.pub.
The key fingerprint is:
41:02:9d:2a:2b:1b:f6:d5:07:ab:35:64:bf:02:ad:58 sync_user@HOME001.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|    .o...        |
|      oo         |
|     .  .        |
|  . .  + .       |
|.+. + = o .      |
|.  o o . .       |
|        .        |
+-----------------+
[sync_user@HOME001 ~]$
[sync_user@HOME001 ~]$ scp .ssh/id_rsa.pub home002:/home/sync_user/.ssh/authorized_keys
sync_user@home002's password:
id_rsa.pub                                                    100%  411     0.4KB/s   00:
[sync_user@HOME001 ~]$

起動するスクリプトの設定

[root@HOME001 sync_user]# vi /etc/rc.d/init.d/lsyncd
[root@HOME001 sync_user]# cat /etc/init.d/lsyncd
#!/bin/bash
#
# lsyncd
#
# chkconfig: - 99 20
# description: lsyncd auto start script

start() {
    /usr/local/bin/lsyncd /etc/lsyncd.conf
}

stop() {
    /bin/kill -9 `/sbin/pidof lsyncd`
    until [ -z $(/sbin/pidof lsyncd) ]; do :; done
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    status)
        pid=`pidof lsyncd`
        if [ $? -eq 0 ]; then
            echo "lsyncd (pid $pid) is running..."
        else
            echo "lsyncd is not running"
        fi
        ;;
    *)
        echo "Usage: lsyncd {start|stop|restart|status}"
        exit 1
esac

exit $?

[root@HOME001 sync_user]# chmod 755 /etc/init.d/lsyncd

[root@HOME001 local]# /sbin/chkconfig lsyncd on
[root@HOME001 local]# /sbin/chkconfig --list lsyncd
lsyncd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@HOME001 local]# 

chkconfig
chkconfig

サービス起動確認
start

基本ファイル同期動作確認
送信元、送信先、送信ログ
lsync_confirmation

追加検証(追加、削除)

-- 送信元にてファイル作成と削除
[root@HOME001 sync_user]# ls -l /home/sync_user/lsync/
合計 8
-rw-r--r--. 1 sync_user sync_user 3300  1月  7 16:12 2013 lsyncd.log
-rw-rw-r--. 1 sync_user sync_user    0  1月  8 15:04 2013 lsyncd_test001
-rw-rw-r--. 1 sync_user sync_user    0  1月  8 15:04 2013 lsyncd_test002
-rw-r--r--. 1 root      root         0  1月  8 16:43 2013 lsyncd_test003
drwxrwxr-x. 2 sync_user sync_user 4096  1月  8 15:20 2013 nonsync
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test004
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test005
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test006
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test007
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test008
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test009
[root@HOME001 sync_user]# touch /home/sync_user/lsync/lsyncd_test010
[root@HOME001 sync_user]# rm /home/sync_user/lsync/lsyncd_test001
rm: remove 通常の空ファイル `/home/sync_user/lsync/lsyncd_test001'? y
[root@HOME001 sync_user]# rm /home/sync_user/lsync/lsyncd_test002
rm: remove 通常の空ファイル `/home/sync_user/lsync/lsyncd_test002'? y
[root@HOME001 sync_user]# rm /home/sync_user/lsync/lsyncd_test003
rm: remove 通常の空ファイル `/home/sync_user/lsync/lsyncd_test003'? y
[root@HOME001 sync_user]#

---- ログ
Tue Jan  8 16:43:41 2013 Normal: Calling rsync with filter-list of new/modified files/dirs
/lsyncd_test003
Tue Jan  8 16:43:41 2013 Normal: Finished a list after exitcode: 0
Tue Jan  8 16:44:06 2013 Normal: Calling rsync with filter-list of new/modified files/dirs
/lsyncd_test004
/lsyncd_test005
Tue Jan  8 16:44:07 2013 Normal: Finished a list after exitcode: 0
Tue Jan  8 16:44:45 2013 Normal: Calling rsync with filter-list of new/modified files/dirs
/lsyncd_test006
/lsyncd_test007
/lsyncd_test008
/lsyncd_test009
/lsyncd_test010
Tue Jan  8 16:44:46 2013 Normal: Finished a list after exitcode: 0
Tue Jan  8 16:45:42 2013 Normal: Calling rsync with filter-list of new/modified files/dirs
/lsyncd_test001
/lsyncd_test002
/lsyncd_test003
Tue Jan  8 16:45:43 2013 Normal: Finished a list after exitcode: 0

---- 同期先にファイルが同期(追加・削除)が反映されている事を確認。

[root@HOME002 sync_user]# ls -l /home/sync_user/lsync/
合計 36
-rw-r--r-- 1 sync_user sync_user 3300  1月  7 16:12 lsyncd.log
-rw-r--r-- 1 root      root         0  1月  8 15:04 lsyncd_test001
-rw-r--r-- 1 root      root         0  1月  8 15:04 lsyncd_test002
-rw-r--r-- 1 root      root         0  1月  8 16:43 lsyncd_test003
-rw-r--r-- 1 root      root         0  1月  8 16:43 lsyncd_test004
-rw-r--r-- 1 root      root         0  1月  8 16:43 lsyncd_test005
drwxr-xr-x 2 root      root      4096  1月  8 15:20 nonsync
[root@HOME002 sync_user]# ls -l /home/sync_user/lsync/
合計 44
-rw-r--r-- 1 sync_user sync_user 3300  1月  7 16:12 lsyncd.log
-rw-r--r-- 1 root      root         0  1月  8 16:43 lsyncd_test004
-rw-r--r-- 1 root      root         0  1月  8 16:43 lsyncd_test005
-rw-r--r-- 1 root      root         0  1月  8 16:44 lsyncd_test006
-rw-r--r-- 1 root      root         0  1月  8 16:44 lsyncd_test007
-rw-r--r-- 1 root      root         0  1月  8 16:44 lsyncd_test008
-rw-r--r-- 1 root      root         0  1月  8 16:44 lsyncd_test009
-rw-r--r-- 1 root      root         0  1月  8 16:44 lsyncd_test010
drwxr-xr-x 2 root      root      4096  1月  8 15:20 nonsync
[root@HOME002 sync_user]#

Excludeの設定有効性確認

-----lsyncd.conf
[root@HOME001 lsync]# cat /etc/lsyncd.conf
settings  {
        statusFile = "/tmp/lsyncd.stat",
        statusInterval = 1,
        logfile="/var/log/lsyncd.log",
}

sync {
        default.rsync,
        source="/home/sync_user/lsync/",
        target="HOME002:/home/sync_user/lsync/",
        exclude={"/nonsync/"},
}

[root@HOME001 lsync]#

-----実行コマンド
[root@HOME001 lsync]#dd if=/dev/zero of=/home/sync_user/lsync/should-be bs=1M count=10
[root@HOME001 lsync]#dd if=/dev/zero of=/home/sync_user/lsync/nonsync/should-not-be bs=1M count=10

-----ファイル確認 (HOME001: 同期元)
[root@HOME001 lsync]# ls -lh
合計 11M
drwxrwxr-x. 2 sync_user sync_user 4.0K  1月  9 15:08 2013 nonsync
-rw-r--r--. 1 root      root       10M  1月  9 15:08 2013 should-be
[root@HOME001 lsync]# ls -lh nonsync/
合計 10M
-rw-r--r--. 1 root root 10M  1月  9 15:08 2013 should-not-be
[root@HOME001 lsync]#

-----ファイル確認(HOME001: 同期先)
[root@HOME002 lsync]# ls -lh
合計 11M
drwxr-xr-x 2 root root 4.0K  1月  9 14:48 nonsync
-rw-r--r-- 1 root root  10M  1月  9 15:08 should-be
[root@HOME002 lsync]# ls -lh nonsync/
合計 0
[root@HOME002 lsync]#

exclude

設定メモ:
バージョンが異なるrsyncが共存するとエラーになってしまったので、
送信元と送信先のrsyncのバージョンを合わせました。

エラー

rsync: on remote machine: -sltre.iLs: unknown option
rsync error: syntax or usage error (code 1) at main.c(1231) [server=2.6.8]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]

log_confirmation

エラーが発生したバージョン

[root@HOME001 ~]# rsync --version
rsync  version 3.0.6  protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[root@HOME001 ~]#


[root@HOME002 .ssh]# rsync --version
rsync  version 2.6.8  protocol version 29
Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.
<http://rsync.samba.org/>
Capabilities: 64-bit files, socketpairs, hard links, ACLs, xattrs, symlinks, batchfiles,
              inplace, IPv6, 64-bit system inums, 64-bit internal inums

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[root@HOME002 .ssh]#

送信元と同じバージョンのrsyncをダウンロードし送信先にインストール

[root@HOME002 sync_user]# wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.6.tar.gz
--16:28:00--  http://rsync.samba.org/ftp/rsync/src/rsync-3.0.6.tar.gz
rsync.samba.org をDNSに問いあわせています... 216.83.154.106, 2001:470:1f05:1a07::1
rsync.samba.org|216.83.154.106|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 778927 (761K) [application/x-gzip]
Saving to: `rsync-3.0.6.tar.gz'

100%[===============================================================================================================================>] 778,927     81.0K/s   in 9.4s

16:28:10 (80.9 KB/s) - `rsync-3.0.6.tar.gz' を保存しました [778927/778927]

[root@HOME002 sync_user]#

[root@HOME002 rsync-3.0.6]# ./configure
configure.sh: Configuring rsync 3.0.6
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether to include debugging symbols... yes
checking for gcc... gcc
省略...
config.status: creating popt/dummy
config.status: creating shconfig
config.status: creating config.h

    rsync 3.0.6 configuration successful

[root@HOME002 rsync-3.0.6]# make
gcc -std=gnu99 -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W  -c flist.c -o flist.o
gcc -std=gnu99 -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W  -c rsync.c -o rsync.o
gcc -std=gnu99 -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W  -c generator.c -o generator.o
省略...
rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[root@HOME002 rsync-3.0.6]# make install
mkdir -p /usr/local/bin
/usr/bin/install -c  -m 755 rsync /usr/local/bin
mkdir -p /usr/local/share/man/man1
mkdir -p /usr/local/share/man/man5
if test -f rsync.1; then /usr/bin/install -c -m 644 rsync.1 /usr/local/share/man/man1; fi
if test -f rsyncd.conf.5; then /usr/bin/install -c -m 644 rsyncd.conf.5 /usr/local/share/man/man5; fi
[root@HOME002 rsync-3.0.6]# /usr/local/bin/rsync --version
rsync  version 3.0.6  protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, no symtimes

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[root@HOME002 rsync-3.0.6]#

rsyncのアップグレード後にエラーログが消えた事とファイル同期された事を確認。

参考:

rsync
Lsyncd – Live Syncing (Mirror) Daemon
xinetd のセットアップ
lsyncdでリアルタイムrsync
リアルタイムミラーリングツール導入(lsyncd+rsyncd)
lsyncd を使ったファイルのミラーリング・バックアップ

Comments are closed.

Post Navigation