码迷,mamicode.com
首页 > 系统相关 > 详细

linux rsync

时间:2016-04-14 16:11:02      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:linux   守护   

开源  快速 多功能 全量及增量   本地远程

已守护进程(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   hequan@192.168.10.11:~             -e指定通道

拉pull

$ rsync  -avz   -e ‘ssh‘    hequan@192.168.10.11:~/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    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    

创建rsync用户      授权

创建密码文件,   复制配置文件里的路径,然后添加密码内容

     内容虚拟用户名:密码

密码文件的权限

rsync  --daemon  

密码文件和服务端没有关系

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

/etc/rsync.password   600

同步

     推  拉 

  


本文出自 “何全” 博客,请务必保留此出处http://hequan.blog.51cto.com/5701886/1763780

linux rsync

标签:linux   守护   

原文地址:http://hequan.blog.51cto.com/5701886/1763780

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!