rsync部署及使用说明

服务端:

1.以本机为rsync服务端,ip地址:xxx.xxx.xxx.xxx

2.rsync服务端配置文件说明:
cat /etc/rsyncd.conf #文件路径

uid=root #用户
gid=root #用户组
max connections=2000 #最大连接数
timeout=600 log
file=/var/log/rsyncd.log #日志文件 pid file=/var/run/rsyncd.pid #pid文件 lock file=/var/run/rsyncd.lock #锁文件 secrets file=/etc/rsyncd.passwd #虚拟用户对应的用户和密码文件 hosts deny=172.16.78.0/22 #指定不允许连接rsync服务器的机器 [backup_zom] #模块名,客户端使用同步语句需要用到 comment= zom数据备份 #描述 path=/data/back_s001a/databack/zom/dbbackup/ #文件备份路径 read only = no #允许客户端只读 no exclude=test #排除的目录test auth users=zom #认证用户

vim /etc/xinetd.d/rsync

service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

3.创建备份路径:mkdir -p /data/back_s001a/databack/zom/dbbackup/

4.配置账号密码:cat /etc/rsyncd.passwd && chmod 600 /etc/rsyncd.passwd

5.重启生效:/etc/init.d/xinetd restart / rsync --daemon --config=/etc/rsyncd.conf [后面的启动方式似乎不会出现被拒绝连接Connection refused (111)的问题]


客户端使用:

1.配置密码文件:echo "GZQPxxxxxx" > /etc/rsyncd.scrt && chmod 600 /etc/rsyncd.scrt,密码与/etc/rsyncd.passwd对应账号的密码一样

2.使用:

推送:rsync -azv --bwlimit=2000 --password-file=/etc/rsyncd.scrt [需要同步的文件或文件夹] zom@xxx.xxx.xxx.xxx::backup_zom

拉取:
拉取整个模块下的目录:rsync -azv --bwlimit=2000 --password-file=/etc/rsyncd.scrt zom@10.0.0.xxx::backup_zom ./
      拉取指定目录:rsync -azv --bwlimit=2000 --password-file=/etc/rsyncd.scrt zom@10.0.0.xxx::backup_zom/mydir ./

新发现的使用方式【后面可指定目录,不用建那么多配置】:
  rsync -avzu  -P  --exclude='log*' --progress --timeout 600 --bwlimit=100 --password-file=/etc/rsyncd.scrt $SEND_BACK_DIR ${rsync_user}@${DIST_IP}::${backup_module_name}/${rsync_dir}/log

 

posted @ 2021-06-30 20:19  chenjianwen  阅读(119)  评论(0编辑  收藏  举报