Linux Rsync 安裝使用詳解

2019-08-02 rsync的初次嘗試

沒啥好說的,用來處理服務器之間的操作命令,比如日誌備份,服務器之間數據複製等

第一步安裝:apt-get install rsync

準備兩臺服務器進行測試

一臺:192.168.33.10  服務端
一臺:192.168.33.11  客戶端(執行操作一端,也可以反着操作)

第二部 進行配置

服務端配置:
cat /etc/rsyncd.conf 內容如下
uid = root 
gid = root
fake super = yes
use chroot = no
max connections = 10
strict mode = yes
port = 873
timeout = 1000
[backup]
path = /root/test //操作目錄
comment = Root Dir
ignore errors
read only = yes  //是否可讀
list = no
auth users = root //執行用戶,一般不是root用戶
secrets file = /etc/rsync.sec //用戶密碼,需要分號分割
log file = /var/log/rsyncd.log

cat /etc/rsync.sec 內容如下
root:asdfasdf

授權
chmod 600 /etc/rsync.sec
客戶端配置:
cat /etc/rsync.sec 內容如下
asdfasdf //只用配置密碼

授權
chmod 600 /etc/rsync.sec

第三部服務端rsync服務啓動

rsync --daemon --config=/etc/rsyncd.conf 
#查看端口是否允許
netstat -a | grep rsync

進行測試

#複製文件
rsync -arvz /var/log/access.log [email protected]:/tmp
#同步文件(從服務端拉取數據)
rsync -vzrtopg  --progress  --password-file=/etc/rsync.sec --port=873 [email protected]::backup  /rsync_dir
#寫數據(往服務端寫數據)
rsync -vzrtopg --delete --progress /var/log/access.log [email protected]::backup  --password-file=/etc/rsync.sec --port=873
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章