rsync特性和三种模式

2023年 7月 16日 39.6k 0

rsync增量备份rsync全程Remote synchronization,远程同步远程cp: ssh自带的scp命令本地cp: cp删除功能: rmrsync可以提供一个网络服务(port,socket)

在同步数据时,默认情况下,rsync通过其独特的“quick check”算法,它仅同步大小或者最后修改时间发生变化的文件和目录,并且可以根据权限,属主属组的变化同步,需要额外指定参数,甚至可以同步一个文件里有变化的内容部分,所以可以实现快速的同步备份数据!

rsync特性 rsync特性如下:https://www.samba.org/ftp/rsync/rsync.html1,支持复制特殊文件和连接文件,设备等2,可以有排除指定文件或目录同步的功能,相当于打包3,可以做到保存源文件和目录的权限,时间软硬连接,属主属组所有属性均不改变4,可以实现增量同步,既只同步发生变化的数据5,通过rcp,rsh,ssh等方式来传输(他本身不对数据加密)6,可以通过socket(进程方式)传输文件和数据(cs)7, 支持匿名认证的进场传输模式,可以实现方便安全的进行数据备份和镜像

Rsync工作方式!Local:本地传输

-avz:保持属性不变

[root@node ~]# rsync -avz /etc/hosts /tmp/
sending incremental file list
hosts

sent 124 bytes  received 31 bytes  310.00 bytes/sec
total size is 158  speedup is 1.02
[root@node ~]# 

--delete /linuxea/ /tmp/ 将linux目录下的数据和tmp数据同步,tmp的数据绝对和linuxea中内容一致

[root@node tmp]# mkdir /linuxea
[root@node tmp]# rsync -avz --delete /linuxea/ /tmp

二,隧道访问pull: 拉取 local-->SRC--->destpush: 推送 src---->host-->dest

推送如下:将opt下1.txt,保持属性,-e使用ssH隧道推送到10.0.0.25:/tmp/linuxea下,原来10.0.0.25:/tmp/linuxea下的文件不会覆盖,只会追加

[root@node opt]# touch 1.txt
[root@node opt]# echo 123456 > 1.txt 
[root@node opt]# rsync -avzp -e 'ssh -p 22' /opt/ root@10.0.0.25:/tmp/linuxea
The authenticity of host '10.0.0.25 (10.0.0.25)' can't be established.
RSA key fingerprint is b8:e2:26:b5:fb:b4:42:31:11:f8:15:45:71:0b:68:61.
Are you sure you want to continue connecting (yes/no)? yes    
Warning: Permanently added '10.0.0.25' (RSA) to the list of known hosts.
root@10.0.0.25's password: 
sending incremental file list
./
1.txt
rh/

sent 120 bytes  received 38 bytes  15.05 bytes/sec
total size is 7  speedup is 0.04
[root@node opt]# 

查看,已经存在

[root@jumo-client tmp]# cd linuxea/
[root@jumo-client linuxea]# ls
1.txt  rh
[root@jumo-client linuxea]# cat 1.txt 
123456
[root@jumo-client linuxea]#

拉取如下:通过ssh拉取10.0.0.25:/tmp/linuxea/目录下所有文件到/tmp下

[root@node opt]# rsync -avzp -e 'ssh -p 22' root@10.0.0.25:/tmp/linuxea/ /tmp/
root@10.0.0.25's password: 
receiving incremental file list
./
1.txt
rh/

sent 37 bytes  received 125 bytes  24.92 bytes/sec
total size is 7  speedup is 0.04
[root@node opt]# cat /tmp/1.txt 
123456
[root@node opt]# 

三Access via rsync daemon服务访问

参数选项:

-v,详细输出
-z,传输时候亚索
-a,归档模式
-r, 递归
-t,时间
-o,保持文件属主
-p,保持文件权限
-g,保持文件数组
-p, 显示同步的过程及传输时的进度等信息
-d,保持设备文件信息
-l,保持软连接
-e,--rsh=COMMAND使用的信道协议,指定替代rsh的shell程序
如下:
--exclude=PATTERN指定排除不需要传输的文件模式
--exclude-from=file(文件名所在的目录文件)
--bwlimit=RATE  socket I/O

20090830125439-489386988.jpg

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论