• rsync 使用小记


    工作中遇到了有关rsync使用的问题,在这里记录下供有同样需求的人参考一下

    先说下环境

    服务端配置

    pid file = /rsyncdata/rsyncd.pid
    port = 873
    address = 0.0.0.0
    charset = UTF-8
    reverse lookup = no
    uid = 0
    gid = 0
    use chroot = no
    hosts allow = 127.0.0.1 10.10.0.0/255.255.0.0 
    log format = %o %h [%a] %m (%u) %f %l
    log file = /rsyncdata/logs/rsyncd.log
    read only = no
    max connections = 1000
    transfer logging = yes
    exclude = lost+found/
    fake super = yes
    timeout = 900
    
    # sub config
    
    [mysql-back]
    path = /rsyncbak/dbback/mysql-back
    comment = mysql-back
    read only = no
    auth users = backuser
    hosts allow = *
    secrets file = /etc/rsync.password
    dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.z
    log file = /rsyncdata/logs/rsyncd_mysql-back.log
    

     采用密码文件认证的方式传输,客户端要保证密码文件存在,且权限为600

    客户端待传输的目录结构为/mysql/backup/${port}/data/${date}

    需求是,将${port}下的最新备份集传输到rsync server,但是server端如果不存在上级目录${port}/data则自动创建

    使用喧嚣 R可以实现这一目的,所以最终的传输命令为

    cd /mysql/backup
    /usr/bin/rsync -avrPR ./${port}/data/${lastest_date} backuser@${rsync_server}::mysql-back --password-file=/etc/rsync.password 
  • 相关阅读:
    shell脚本之数组
    shell脚本之函数
    shell脚本之sed
    shell脚本的for循环与read
    shell脚本之if语句
    shell脚本正则表达式
    shell的编程原理
    《梦断代码》阅读笔记03
    12.19学习总结
    《梦断代码》阅读笔记02
  • 原文地址:https://www.cnblogs.com/Bccd/p/9144205.html
Copyright © 2020-2023  润新知