rsync(d)服务端启动两种方式
1.daemon 2.xinetd inetd
启动后绑在 TCP/873 端口
% cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
配置 注意设置读写权限属主
% cat /etc/rsyncd.conf
motd file = /var/log/rsync/welcome.msg
pid file = /var/log/rsync/rsyncd.pid
lock file = /var/log/rsync/rsync.lock
log file = /var/log/rsync/rsyncd.log
[rsyncwww]
comment = rsync www
path = /var/www/
use chroot = no
max connections = 4
read only = false
list = true
uid = nobody
gid = nobody
auth users = wwwuser
secrets file = /etc/rsyncd.secrets
hosts allow = 1.1.1.1,2.2.2.2
hosts deny = 0.0.0.0/0
ignore errors = yes
transfer logging = yes
log format = "%a %f %l"
#log format = "%o %h [%a] %m (%u) %f %l"
[rsyncroot]
comment = rsync root
path = /
use chroot = no
max connections = 4
read only = true
#read only = false
list = true
uid = root
gid = root
auth users = rootuser
secrets file = /etc/rsyncd.secrets
hosts allow = 1.1.1.1,2.2.2.2
hosts deny = 0.0.0.0/0
ignore errors = yes
transfer logging = yes
log format = "%a %f %l"
rsyncd.secrets 一行一个用户 用户名:密码 格式
使用
rsync -auvPz --progress dir1 dir2
rsync -ztruvoglpD --progress dir1 dir2
rsync -ztruvoglpD --progress dir1/ dir2
rsync -ztruvoglpD --progress dir1/file1 dir2
如果不想包含某个目录/文件可以设置--exclude
远程使用
rsync 1.1.1.1:: 只列list
rsync user@1.1.1.1::
rsync user@1.1.1.1::module
rsync user@1.1.1.1::module/path
如果没有配置rsync server 可以通过 ssh 方式使用
rsync -e ssh -auvPz 1.1.1.1:/etc ./
同步时注意注意 / 最后的问题
不放/ 则目录名也包含mirror
放 / 则只有目录里面的东西mirror了
rsync -ztruvoglp --progress user@1.1.1.1::module/path ./
为了脚本调用方便 还可以调用 --password-file 同样注意属主权限
也可以设置环境变量RSYNC_PASSWORD=访问含用户认证的rsync
rsync 数据同步使用详解
2020-11-19 16:29服务器技术网 服务器知识
rsync 是很强大的同步工具 本地远程皆宜 不少project都提供 http ftp rsync 等mirror方式 rsync官方主页是 http://samba.anu.edu.au/rsync/
延伸 · 阅读
- 2023-03-17浅谈MySQL数据同步到 Redis 缓存的几种方法
- 2022-10-31Linux利用inotify和rsync服务实现数据实时同步的原理
- 2022-10-08SpringBoot整合canal实现数据同步的示例代码
- 2022-09-29使用mongoshake实现mongodb数据同步的操作方法
- 2022-09-08MySQL 到 ClickHouse 实时数据同步实操
- 2022-09-01MySQL 到Oracle 实时数据同步
- 服务器知识
Docker定制容器镜像的2种方法(推荐)
本篇文章主要介绍了Docker定制容器镜像的2种方法(推荐),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...
- 服务器知识
构建及部署jenkins pipeline实现持续集成持续交付脚本
这篇文章主要为大家介绍了构建及部署jenkins pipeline实现持续集成持续交付脚本,哟需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步...
- 服务器知识
docker时区问题和迁移数据问题
这篇文章主要介绍了docker时区问题和迁移数据问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下...
- 服务器知识
Dell服务器固件升级
描述 固件英文单词FirmWare,例如硬盘控制器、内存控制器、bios、远程控制卡等等固件。升级之前需要安装OpenManage,不会的请看Dell服务器安装OpenManage(OMSA),升...
- 服务器知识
iptables + Denyhost抵御暴力破解
使用iptables 现在每分钟连接ssh的次数 #允许本地环回接口访问iptables -A INPUT -i lo -j ACCEPT#对已经建立的所有链接都放行iptables -A INPUT -m state –state ESTABLISHED ...
- 服务器知识
VMware中CentOS 7设置文件夹共享的方法
这篇文章主要介绍了VMware中CentOS 7设置文件夹共享的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...
- 服务器知识
Linux系统安装docker并用ssh登录docker容器的操作方法
今天小编就为大家分享一篇Linux系统安装docker并用ssh登录docker容器的操作方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...
- 服务器知识
Apache No space left on device: mod_rewrite: could not create rewrite_log_lock Co
这篇文章主要介绍了Apache No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed问题的解决方法,需要的朋友可以参考下...