zoukankan      html  css  js  c++  java
  • rsync 服务搭建

    rsync 服务搭建

    服务端部署操作内容:

    • 创建rsync用户和用户组
    eg:
        useradd -s /sbin/nologin -M rsync
    
    • 创建需要备份的指定目录,并修改权限
    eg:
        mkdir -p /backup/
        chown -R rsync:rsync /backup
    
    • 创建rsync密码文件,录入密码并修改权限为600
    eg:
        echo "rsync_backup:passwd@123" >/etc/rsync.password 	###注意:服务端的密码文件中包含认证用户和密码
        chmod 600 /etc/rsync.password
    
    • 修改配置文件/etc/rsyncd.conf
    eg:
        cat /etc/rsyncd.conf
        
        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 
        ignore errors 
        read only = false 
        list = false 
        hosts allow = 192.168.217.0/24
        hosts deny = 0.0.0.0/32 
        auth users = rsync_backup 			###认证用户
        secrets file = /etc/rsync.password 	 ###密码文件路径
        [backup] 
        path = /backup
        ###可加其它模块###
    

    服务端启动服务并加入开机启动项

    启动服务:
    rsync --daemon
    rsync --daemon --config=/etc/rsyncd.conf
    
    检查服务启动情况:
    # netstat -anltup |grep 873
    tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      68849/rsync         
    tcp6       0      0 :::873                  :::*                    LISTEN      68849/rsync  
    
    加入开机启动项:
    echo "/usr/bin/rsync --daemon" >> /etc/rc.local
    

    客户端部署操作内容:

    创建rsync密码文件,录入密码并修改权限为600

    eg:
    echo "passwd@123" >/etc/rsync.paasword 		###客户端密码文件只包含密码
    chmod 600 /etc/rsync.paasword
    

    完成部署后,创建文件测试:

    服务端备份路径下文件检查:
    cd /backup/ && ll
    total 0
    
    客户端创建测试文件:
    echo "rsync file test 123" > rsync-test.txt
    
    执行备份:
    # rsync -avz -P rsync-test.txt  rsync_backup@192.168.217.114::backup --password-file=/etc/rsync.password
    sending incremental file list
    rsync-test.txt
                 20 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)
    rsync: chgrp ".rsync-test.txt.8p4xO9" (in backup) failed: Operation not permitted (1)
    
    sent 121 bytes  received 133 bytes  508.00 bytes/sec
    total size is 20  speedup is 0.08
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
    
    服务端检查备份情况:
    # ll
    total 4
    -rw------- 1 rsync rsync 20 Aug 18 15:20 rsync-test.txt
    # cat rsync-test.txt 
    rsync file test 123
  • 相关阅读:
    检测登录按钮 ,回车即登录
    [转]程序变量命名推荐规范
    [NET].NET Framework 3.5 SP1 真正的离线安装(转)
    Arthas使用教程[转载]
    Python中Hamcrest断言的使用
    C#中查询不支持中文的解决方法
    如何防止C#的小黑窗关闭
    AWS的EC2 micro instance真是慢啊
    一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
    自己写的可以布置多个button在同一行的ActionSheet (iPhone)
  • 原文地址:https://www.cnblogs.com/liuxc83/p/15157007.html
Copyright © 2011-2022 走看看