server端(xinetd裡用chkconfig rsync on)
建 /etc/rsyncd.conf 主配置檔案
/etc/rsyncd.motd 登入資訊
/etc/rsyncd.secrets 密碼檔案,權限必須是600 格式:leo:123456
配置server端的/etc/rsyncd.conf檔案
bash-2.03# cat /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = no # 不使用chroot
max connections = 4 # 最大連接配接數為4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log # 日志記錄檔案
[inburst] # 這裡是認證的子產品名,在client端需要指定
path = /home/inburst/python/ # 需要做鏡像的目錄(同步的是該目錄下的檔案)
comment = BACKUP CLIENT IS SOLARIS 8 E250
ignore errors # 可以忽略一些無關的IO錯誤
read only = yes # 隻讀
list = no # 不允許列檔案
auth users = leo # 認證的使用者名,如果沒有這行,則表明是匿名
secrets file = /etc/rsyncd.secrets # 認證檔案名
[web]
path = /usr/local/apache/htdocs/
comment = inburst.org web server
client端
建/etc/rsyncd.secrets 權限600 格式: 123456
同步指令
rsync -avzP --delete [email protected]::home /tmp --password-file=/etc/rsyncd.secrets
-a 相當于 -rlptgoD
-v 顯示同步檔案
-z 壓縮
-P 顯示檔案同步百分比、傳輸速率
--delete 删除目标目錄中多于源目錄的檔案
-------------------------------------------------------------------------------------------
先做私鑰認證
rsync -av /u02/applications/focweb/ -e ssh 192.168.165.15:/defaultroot/focweb
[root@blogap abc]# ll /root/leo
總計 4
-rw-r--r-- 1 root root 0 06-12 16:33 aaa
-rw-r--r-- 1 root root 0 06-12 16:23 abc
-rw-r--r-- 1 root root 0 06-12 16:23 abcd
-rw-r--r-- 1 root root 0 06-12 16:24 abcde
-rw-r--r-- 1 root root 0 06-12 16:33 bbb
-rw-r--r-- 1 root root 8 06-12 16:33 file
rsync -avzP /root/leo/ /tmp/abc (源後面有/表示隻同步檔案夾下的檔案)【abc目錄會自動建立】
[root@blogap abc]# ll
rsync -avzP /root/leo /tmp/abc (源後面無/表示同步leo檔案夾)【abc目錄會自動建立】
drwxr-xr-x 2 root root 4096 06-12 16:33 leo
本文轉自leonardos51CTO部落格,原文連結:http://blog.51cto.com/leomars/487417 ,如需轉載請自行聯系原作者