天天看點

rsync同步檔案

rsync是linux系統下的資料備份同步工具,可以鏡像儲存整個目錄樹和檔案系統;也支援增量備份(這個算法隻傳送兩個檔案的不同部分),保持原來檔案的權限、時間、軟硬連結等附加資訊

負責發起rsync同步操作的客戶機稱為發起端,而負責響應來自客戶機的為同步源。再同步過程中,同步源負責提供文檔的原始位置,而發起端對該位置具有讀取權限,最後同步到本地

系統:centos7.5

##注釋

#systemctl stop firewalld --關閉防火牆

1.

#yum -y install rsync

2.

#useradd -s /sbin/nologin -M rsync

#id rsync

uid=1000(rsync) gid=1000(rsync) 組=1000(rsync)

3.

#vim /etc/rsyncd.conf

uid = rsync

gid = rsync

use chroot = yes

auth users = leshan

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log

secrets file = /etc/rsyncpw

hosts allow = 10.41.104.0/24

#exclude = lost+found/

transfer logging = yes

max connections = 1

timeout = 900

ignore nonreadable = yes

dont compress = .gz .tgz .zip .z .Z .rpm .deb .bz2

[backup]

path = /root/backup

comment = backup test

read only = no

list = false

4.密碼檔案

#echo "leshan:123" > /etc/rsyncpw

#cat /etc/rsyncpw

leshan:123

#chmod 600 /etc/rsyncpw

#ll /etc/rsyncpw

-rw------- 1 root root 11 8月 31 11:04 /etc/rsyncpw

繼續閱讀