安装

  • linux yum install rsync

配置

编辑文件:

vim /etc/xinetd.d/rsync

内容如下:

# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#   allows crc checksumming etc.
service rsync
{
    disable         = no
    flags           = IPv6
    socket_type     = stream
    wait            = no
    user            = root
    server          = /usr/bin/rsync
    server_args     = --daemon
    log_on_failure  += USERID
}

创建配置文件

touch /etc/rsyncd.conf

内容如下

# rsync 服务执行的所属用户 ID 与组 ID
uid = root 
gid = root
use chroot = no
max connections = 0   
port = 873               
pid file = /var/log/rsync/rsyncd.pid   
lock file = /var/log/rsync/rsync.lock
log file = /var/log/rsync/rsyncd.log  
motd file = /var/log/rsync/rsyncd.motd  
strict modes = yes 
# 配置的模块名称
[htdocs]            
uid = root 
gid = root 
path = /var/www/html  
comment = BACKUP attachment                
ignore errors = yes           
read only = false            
list = false # 多个用英文半角空格隔开 
hosts allow = 61.135.152.203 
hosts deny = 172.25.0.0/24 
# 验证的用户名 
auth users = root                      
secrets file = /etc/rsyncd.secrets  

创建验证文件

touch /etc/rsyncd.secrets

内容如下,且权限需为 600

root:1234567890

启动服务

运行如下命令(服务器端)

/usr/bin/rsync --daemon --config=/etc/rsyncd.conf

同步服务器文件到本地

rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.passwd root@192.168.18.200::htdocs ./

/etc/rsyncd.passwd 内容如下

1234567890

同步本地文件到服务器

rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.passwd root@192.168.18.200::htdocs ./

参考文章:http://www.cnblogs.com/mchina/p/2829944.html

Share:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.