Skip to content
网游世界
网游世界

吾生有涯,而知无涯。

  • 首页
  • PHP
    • ThinkPHP
    • FastAdmin
    • webman
  • JavaScript
    • jQuery
    • AdminLTE
  • Free Pascal
  • Java
    • JeeSite
    • 若依
    • ruoyi-vue-pro
  • 其它
    • 操作系统
    • 树莓派
    • 前端
    • Null
  • 关于
网游世界

吾生有涯,而知无涯。

再说 rsync

3Vshej, 2025年1月7日 周二2025年4月23日 周三

rsync 自是不用说了,用于文件同步。

1、安装

yum install rsync
# 或
apt-get install rsync

2、配置

注意:通常情况下,配置文件中 uid、gid 使用 nobody 是没问题的,但某些时间会报错 Permission denied (13)。

这时候,你需要使用 id www 命令,通过它来查询 www 用户信息并填入。(不建议使用 0 值,因为它是 root 用户)

vi /etc/rsyncd.conf

port = 873
uid = nobody
gid = nobody
use chroot = yes
max connections = 4
syslog facility = local5
pid file = /tmp/rsyncd.pid

[www]
path = /www/wwwroot/
uid = www
gid = www
comment = wwwroot site
read only = true
auth users = rsync
secrets file = /etc/rsyncd.password

[db_backup]
path = /www/backup/database/
uid = backup
gid = backup
comment = database backup
read only = true
auth users = db_rsync
secrets file = /etc/rsyncd.password

3、登录密码

vi /etc/rsyncd.password

rsync:rsyncpasswd
db_rsync:dbpasswd

4、设置权限

chmod 600 /etc/rsyncd.password

5、开机启动

echo "/usr/bin/rsync --daemon" >> /etc/rc.local
chmod +x /etc/rc.local

6、首次运行

rsync --daemon

客户端设置

1、设置密码

vi /etc/rsyncd.password

rsync:rsyncpasswd
db_rsync:dbpasswd

2、设置权限

chmod 600 /etc/rsyncd.password

3、设置忽略目录

vi /etc/rsyncd_www_rules

- /demo.com/logs

4、执行同步命令

rsync -vzrtopg --port=873 --progress --delete --password-file=/etc/rsyncd_www.password --exclude-from=/etc/rsyncd_www_rules rsync@domain.com::www /tmp/test

5、推送(发送文件)

rsync -avz --progress --bwlimit=5120 -e "ssh -p 666" /www/clone/ root@domain.com:/www/wwwroot/clone/

bwlimit 参数为限制速度,单位 KB。

相关:

  • rsync 官网
  • 使用 rsync 命令使用–增量、全量同步备份文件
  • rsync用法详解:最全面的rsync使用指南
  • rsync 用法教程
  • 记一次简单的 rsync 使用

相关文章:

  1. Windows 下的 rsync rsync 工具是很方便的文件同步工具,在 Windows 下可以使用 cwrsync。...
  2. Windows BT 面板 404 页乱码 仍是使用 Windows BT 面板遇到的问题:在新建站点后,访问不存在页面时,正常应该返回 404......
  3. FastAdmin BT 面板设置 PHP 上传大小 FastAdmin 使用 BT 面板管理站点,开发中,需要调整上传文件的大小。...
  4. BT 面板 MySQL 修复 has the wrong structure or is missing MySQL 未知原因造成停止服务,查看日志时,发现: [Warning] Optional nati......
其它 操作系统 rsync

文章导航

Previous post
Next post

近期文章

  • Android Studio Gradle 配置国内镜像
  • 为什么重新发明轮子
  • ruoyi-vue-pro 匿名访问
  • VUE 中接收 code 异常
  • 关于 AI

归档

  • 2025 年 4 月
  • 2025 年 3 月
  • 2025 年 2 月
  • 2025 年 1 月
  • 2024 年 12 月
  • 2024 年 11 月
  • 2024 年 10 月
  • 2024 年 9 月
  • 2024 年 8 月
  • 2024 年 7 月
  • 2024 年 6 月
  • 2024 年 5 月
  • 2024 年 4 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2024 年 1 月
  • 2023 年 12 月
除非特殊说明,本站作品采用知识共享署名 4.0 国际许可协议进行许可。
豫公网安备 41010402002622号 豫ICP备2020029609号-3
©2025 3Vshej