本文最后更新于194 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
1. 检查是否安装
apt update
apt install -y rsync
dpkg -l |grep rsync
dpkg -L rsync
2. 配置文件
没有文件创建
进入清空内容再写入
vim /etc/rsyncd.conf
#created by oldboy 15:01 2009-6-5
##rsyncd.conf start##
fake super =yes
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
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 = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
######################################
[data]
comment = www by old0boy 14:18 2012-1-13 path = /data
3. 查看添加虚拟用户
useradd -s /sbin/nologin -M rsync
id rsync
echo 'rsync_backup:1' >/etc/rsync.password
cat /etc/rsync.password
chmod 600 /etc/rsync.password
ll /etc/rsync.password
4. 创建共享目录
mkdir -p /data
chown rsync.rsync /data
ll -d /data
5. 启动服务
systemctl enable --now rsync.service
systemctl restart rsync.service
systemctl status rsync.service
ps -ef |grep rsync
ss -lntup |grep rsync
6. 本机测试
rsync -av /etc/hostname rsync_backup@172.16.1.42::data
Password: 1
ll /data
cat /data/hostname
客户端测试后
cat /data/hostname
7. 客户端测试
rsync -av /etc/hostname rsync_backup@172.16.1.42::data
Password: 1
8. 客户端免密配置
echo '1' >/etc/rsync.client
chmod 600 /etc/rsync.client
ll /etc/rsync.client
rsync -av /etc/hosts rsync_backup@172.16.1.42::data --password-file=/etc/rsync.client
(指定客户端权限 密码权限)
完成后回服务端查看
ll /data