Rsync 為增量同步神器,採用 C/S 架構。本文涵蓋伺服器端(模組模式)與客戶端完整配置,含認證、防火牆、定時同步等生產級細節。
yum -y install xinetd rsync
systemctl enable xinetd --now
vi /etc/xinetd.d/rsync
# 將 disable = yes 改為 disable = no
systemctl restart xinetd
firewall-cmd --permanent --add-port=873/tcp
firewall-cmd --reload
# 或 iptables
iptables -A INPUT -p tcp --dport 873 -j ACCEPT
vi /etc/rsyncd.conf
# Global Settings
uid = root
gid = root
use chroot = no
max connections = 20
secrets file = /etc/rsyncd.secrets
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[backup]
path = /data/www/repos
auth users = rsync
read only = no
hosts allow = 192.168.3.0/24
hosts deny = *
list = true
echo "rsync:StrongPassw0rd!" > /etc/rsyncd.secrets
chmod 600 /etc/rsyncd.secrets
chown root:root /etc/rsyncd.secrets
yum -y install rsync
rsync -avz --progress rsync@192.168.3.191::backup /www
# 僅存放密碼,無使用者名
echo "StrongPassw0rd!" > /etc/rsyncd.pas
chmod 600 /etc/rsyncd.pas
# 完整指令
rsync -vzrtopgu --progress --delete \
--password-file=/etc/rsyncd.pas \
rsync@192.168.3.191::backup /www/
參數解析: -a=保留屬性 -z=壓縮 -u=僅更新 --delete=鏡像刪除
crontab -e
*/3 * * * * rsync -avz --password-file=/etc/rsyncd.pas rsync@192.168.3.191::backup /www/ &>/dev/null
| 需求 | 指令範例 |
|---|---|
| 列出遠端模組 | rsync rsync@192.168.3.191:: |
| 本地目錄同步 | rsync -av --delete /src/ /dst/ |
| SSH 加密傳輸 | rsync -avz -e ssh /src/ user@host:/dst/ |
| 排除特定目錄 | rsync -av --exclude='cache/' /src/ /dst/ |
600,否則拒絕連線-u 判斷失效-W (整檔傳輸) 提升效能R525 G2 伺服器 RJ-45 序列埠 (COM A) 與主板內建序列埠 (COM B) 腳位定義完整版
解決 Windows Server 2003 時間服務 86400 秒未同步警告事件
Windows Server 2003 防木馬權限鎖死與系統加固完整清單
FTP/Web 伺服器架設失敗?四步診斷法精準定位內外網阻斷點
IIS 6.0 ScriptEngine C0000005 異常完整排查指南
IIS 安裝後無法瀏覽 ASP 頁面完整排查指南 (Ghost XP/Win7/Server 2008/2012)
Apache 403 Forbidden 錯誤:You don't have permission to access 完整排查與解決指南