• 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
  • 相关阅读:
    吴太银:华为消费者云服务Cassandra使用场景与最佳实践
    使用FileZilla连接Linux
    debug 与 release
    删除cocos2dx项目模版
    [转]C/C++控制台输出时设置字体及背景颜色
    iphone调试的一些问题
    [转]Refactoring Game Entities with Components
    使用QT + cocos2dx制作工具
    [转]printf输出字体颜色
    Error: No module named books
  • 原文地址:https://www.cnblogs.com/liuxc83/p/15157007.html
Copyright © 2020-2023  润新知