Rsync守护进程服务企业应用

目录

    一、 守护进程多模块功能配置

    二、守护进程的排除功能实践

    三、守护进程来创建备份目录

    四、守护进程的访问控制配置

    五、守护进程的列表功能配置


    一、 守护进程多模块功能配置

    sa  sa_data.txt
    dev dev_data.txt
    dba dba_data.txt
    第一步:
    编辑配置文件
    vim /etc/rsyncd.conf
    [backup]
    comment = "backup dir by yaobin"
    path = /backup
    [dba]
    comment = "backup dir by yaobin"
    path = /dba
    [devdata]
    comment = "backup dir by yaobin"
    path = /devdata
    第二步:
    创建目录
    mkdir /{dba,devdata}
    第三部:
    修改属主属组权限
    chown rsync.rsync /{dba,devdata}
    第四步:
    重启服务
    systemctl restart rsyncd
    


    二、守护进程的排除功能实践


    准备环境:
    [root@nfs01 /]# mkdir -p /yaobin
    [root@nfs01 /]# mkdir -p /yaobin/{a..c}
    [root@nfs01 /]# touch /yaobin/{a..c}/{1..3}.txt
    [root@nfs01 /]# tree /yaobin
    /yaobin
    ├── 01.txt
    ├── 02.txt
    ├── a
    │?? ├── 1.txt
    │?? ├── 2.txt
    │?? └── 3.txt
    ├── b
    │?? ├── 1.txt
    │?? ├── 2.txt
    │?? └── 3.txt
    └── c
        ├── 1.txt
        ├── 2.txt
        └── 3.txt

    需求01: 将/yaobin目录下面 a目录数据全部备份 b目录不要备份1.txt文件 c整个目录不要做备份
    --exclude=PATTERN
    绝对路径方式:
    [root@nfs01 /]# rsync -avz /yaobin --exclude=/yaobin/b/1.txt --exclude=/yaobin/c/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password 
    sending incremental file list
    yaobin/
    yaobin/01.txt
    yaobin/02.txt
    yaobin/a/
    yaobin/a/1.txt
    yaobin/a/2.txt
    yaobin/a/3.txt
    yaobin/b/
    yaobin/b/2.txt
    yaobin/b/3.txt
 
    相对路径方式:
    [root@nfs01 /]# rsync -avz /yaobin --exclude=b/1.txt --exclude=c/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password 
    sending incremental file list
    yaobin/
    yaobin/01.txt
    yaobin/02.txt
    yaobin/a/
    yaobin/a/1.txt
    yaobin/a/2.txt
    yaobin/a/3.txt
    yaobin/b/
    yaobin/b/2.txt
    yaobin/b/3.txt
    
    sent 502 bytes  received 177 bytes  1,358.00 bytes/sec
    total size is 0  speedup is 0.00

    需求02: 将/yaobin目录下面 a目录数据全部备份 b目录不要备份1.txt文件 c整个目录1.txt 3.txt文件不要备份
    --exclude-from=file  --- 批量排除 
    第一个历程: 编辑好一个排除文件
    [root@nfs01 /]# cat /yaobin/exclude.txt 
    b/1.txt
    c/1.txt
    c/3.txt
    exclude.txt

    第二个历程: 实现批量排除功能
    [root@nfs01 /]# rsync -avz /yaobin --exclude-from=/yaobin/exclude.txt rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password 
    sending incremental file list
    yaobin/
    yaobin/01.txt
    yaobin/02.txt
    yaobin/a/
    yaobin/a/1.txt
    yaobin/a/2.txt
    yaobin/a/3.txt
    yaobin/b/
    yaobin/b/2.txt
    yaobin/b/3.txt
    yaobin/c/
    yaobin/c/2.txt

    三、守护进程来创建备份目录


    [root@nfs01 /]# rsync -avz /etc/hosts  rsync_backup@172.16.1.41::backup/10.0.0.31/ --password-file=/etc/rsync.password 
    sending incremental file list
    created directory 10.0.0.31
    hosts
    
    sent 226 bytes  received 75 bytes  602.00 bytes/sec
    total size is 371  speedup is 1.23
    PS: 客户端无法在服务端创建多级目录
    


    四、守护进程的访问控制配置


    守护进程白名单和黑名单功能
    PS: 建议只使用一种名单
    


    五、守护进程的列表功能配置


    [root@nfs01 /]# rsync rsync_backup@172.16.1.41::
    backup             "backup dir by yaobin"
    dba                "backup dir by yaobin"
    dev                "backup dir by yaobin"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值