linux rsync

開源  快速 多功能 全量及增量   本地遠程

已守護進程(socket)的方式傳輸數據

rsync    參數   源   目的

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   [email protected]:~             -e指定通道

拉pull

$ rsync  -avz   -e 'ssh'    [email protected]:~/hosts    /home/hequan/

-v 詳細輸出

-z 壓縮傳輸

-a歸檔模式   =  -rtopgDl    遞歸   保持文件時間   屬主   權限  屬組信息   設備文件信息   軟連接

-e 使用信道協議

daeman 模式

# rsync --version

rsync  version 3.0.6  protocol version 30

# yum install rsync -y

服務器端

# 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  已守護進程的方式啓動

# 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

創建用戶,授權     寫入用戶名密碼

# 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  降低權限

客戶端

# echo "hequan" > /etc/rsync.password            只有密碼

# chmod 600 /etc/rsync.password

#rsync -avz    [email protected]::hequan        /data/                   hequan 是模塊

Password:

receiving incremental file list

./

test1

# rsync -avz    [email protected]::hequan     --password-file=/etc/rsync.password  /data/

# rsync -avz    /data/     [email protected]::hequan     --password-file=/etc/rsync.password 

vi /etc/rsyncd.conf    用戶  目錄 模塊   虛擬用戶 及密碼文件

共享目錄 /hequan    

創建rsync用戶      授權

創建密碼文件,   複製配置文件裏的路徑,然後添加密碼內容

     內容虛擬用戶名:密碼

密碼文件的權限

rsync  --daemon  

密碼文件和服務端沒有關係

  --password-file=/etc/rsync.password      密碼

/etc/rsync.password   600

同步

     推  拉 

  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章