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
  • 相关阅读:
    快速构建ceph可视化监控系统
    Codeforces Round #277.5 解题报告
    【MapReduce】经常使用计算模型具体解释
    Unity3D教程:静态调用C#的dll
    【Oracle错误集锦】:PLSQL无法直连64位Oracle11g数据库
    关于ios下字体描边的一个细节
    未来社交站点:15秒内让你闻名全球 虚拟现实与社交网络融合
    iOS多语言(国际化)开发(尾随系统 + APP内手动设置)
    Java String对象的经典问题
    jsp+tomcat+ 创建project 配置project
  • 原文地址:https://www.cnblogs.com/liuxc83/p/15157007.html
Copyright © 2011-2022 走看看