CentOS之间rsync做文件增量(备份)同步(主动拉取)

本文详细介绍了如何配置rsync服务,包括在两台服务器上安装、启动服务,设置配置文件,以及创建密码文件。接着,展示了rsync命令的用法,包括同步规则、排除文件、定时任务等。在执行同步时遇到了权限问题,原因是SELinux未关闭,通过临时和永久关闭SELinux解决了问题。

服务器

  • 192.168.0.1:备份服务器
  • 192.168.0.2:远程服务器

目的

将远程服务器数据同步到备份服务器

前提

两台服务器安装rsync(服务端、备份端)

yum install -y rsync
#启动rsync服务
systemctl start rsyncd.service
systemctl enable rsyncd.service
systemctl restart rsyncd.service

#检查是否已经成功启动
netstat -lnp|grep 873
#远程服务器(配置文件)(/etc/rsyncd.conf)
# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
#        path = /home/ftp
#        comment = ftp export area

uid = root                              
# //设置运行rsync 进程的用户
gid = root
use chroot = no
max connections = 4
# pid file = /var/run/rsyncd.pid        
#//CentOS7中yum安装不需指定pid file 否则报错
lock file=/var/run/rsyncd.lock
log file = /var/log/rsyncd.log     
# //此文件定义完成后系统会自动创建
exclude = lost+found/
transfer logging = yes
timeout = 900
ignore nonreadable = yes         
# //同步时跳过没有权限的目录
dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2          
#  //传输时不压缩的文件
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值