linux rsync
開源 ?快速 多功能 全量及增量 ? 本地遠(yuǎn)程
已守護(hù)進(jìn)程(socket)的方式傳輸數(shù)據(jù)
rsync ? ?參數(shù) ? 源 ? 目的
SYNOPSIS
? ? ? ?Local:? rsync [OPTION...] SRC... [DEST] ? ? ? ? ? ? ?? ????source 源 ? ? dest目的
? ? ? ?Access via remote shell:
? ? ? ? ?Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST] ? ? ? ? ? ? ? ?
? ? ? ? ?Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
? ? ? ?Access via?rsync daemon:
? ? ? ? ?Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
? ? ? ? ? ? ? ?rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
? ? ? ? ?Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
? ? ? ? ? ? ? ?rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
直接本地同步 ?cp
# rsync??-avz? ?/etc/hosts? /tmp/
刪除文件
# rsync -r? --delete? /null/? ?/hequan/ ? ? ? ? ? 讓/null/(空文件) ?和/hequan/下一樣
推送push
$ rsync ?-avz ??-e?'ssh' ?/etc/hosts ? hequan@192.168.10.11:~ ? ? ? ? ? ? -e指定通道
拉pull
$ rsync ?-avz ??-e?'ssh' ?? hequan@192.168.10.11:~/hosts ? ?/home/hequan/
-v 詳細(xì)輸出
-z 壓縮傳輸
-a歸檔模式 ? = ?-rtopgDl?? ?遞歸 ? 保持文件時間 ? 屬主 ? 權(quán)限 ?屬組信息 ? 設(shè)備文件信息 ? 軟連接
-e?使用信道協(xié)議
daeman 模式
# rsync --version
rsync? version 3.0.6? protocol version 30
# yum install rsync -y
服務(wù)器端
# vim /etc/rsyncd.conf ?配置文件
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[hequan]
path = /hequan/
ignore errors
read only = false
list = false
hosts allow = 192.168.10.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#rsync_config_______________end
#?rsync --daemon??已守護(hù)進(jìn)程的方式啟動
# netstat -lntup | grep?873
tcp? ? ? ? 0? ? ? 0 0.0.0.0:873? ? ? ? ? ? ? ? ?0.0.0.0:*? ? ? ? ? ? ? ? ? ?LISTEN? ? ? 1768/rsync
# cat /var/log/rsyncd.log
2016/03/29 22:53:45 [1768] rsyncd version 3.0.6 starting, listening on port 873
創(chuàng)建用戶,授權(quán) ? ? 寫入用戶名密碼
# useradd rsync? -s /sbin/nologin
# chown? -R? rsync.rsync? /hequan/
# echo "rsync_backup:hequan" > /etc/rsync.password
# cat /etc/rsyncd.password
rsync_backup:hequan
用戶名:密碼
# chmod 600 /etc/rsync.password ?降低權(quán)限
客戶端
# echo "hequan" > /etc/rsync.password ? ? ? ? ? ?只有密碼
# chmod 600 /etc/rsync.password
拉
#rsync -avz ? ?rsync_backup@192.168.10.10::hequan?? ? ? ?/data/ ? ? ? ? ? ? ? ? ? hequan 是模塊
Password:
receiving incremental file list
./
test1
# rsync -avz? ? rsync_backup@192.168.10.10::hequan? ? ?--password-file=/etc/rsync.password? /data/
推
# rsync -avz ? ?/data/ ? ? rsync_backup@192.168.10.10::hequan? ? ?--password-file=/etc/rsync.password?
vi /etc/rsyncd.conf ? ?用戶 ?目錄 模塊 ? 虛擬用戶 及密碼文件
共享目錄 /hequan ? ?
創(chuàng)建rsync用戶 ? ? ?授權(quán)
創(chuàng)建密碼文件, ? 復(fù)制配置文件里的路徑,然后添加密碼內(nèi)容
? ? ?內(nèi)容虛擬用戶名:密碼
密碼文件的權(quán)限
rsync ?--daemon ?
密碼文件和服務(wù)端沒有關(guān)系
? --password-file=/etc/rsync.password ? ? ?密碼
/etc/rsync.password ? 600
同步
? ? ?推 ?拉?
本文轉(zhuǎn)自 295631788 51CTO博客,原文鏈接:http://blog.51cto.com/hequan/1763780,如需轉(zhuǎn)載請自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的linux rsync的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python--day7--面向对象编程
- 下一篇: 强势的老板--项目管理