rsync差异备份和命令排除

2023年 7月 16日 44.8k 0

rsync备份:1,增量备份同步,支持socket(daemon),集中备份rsync缺点:1,大量小文件时候同步的时候,比对时间较长,有的时候,rsync进程停止解决:a,打包同步。b,drbd(文件系统同步复制block)2,同步大文件,10G这样的大文件有时会出问题,中断,未完成同步前,是隐藏文件,同步完成后是正常文件!

无差异同步--delete同步--delete,如下:拉取:本地没有将远端10.0.0.30backup下的文件全部拉取到本地/tmp下,并且将backup内文件同步/tmp下保持一致

[root@jumo-client tmp]# touch 1.txt
[root@jumo-client tmp]# rsync -avz --delete  rsync_backup@10.0.0.30::backup /tmp/ --password-file=/etc/rsync.password
receiving incremental file list
deleting 1.txt
./

    sent 78 bytes  received 2401 bytes  708.29 bytes/sec
    total size is 294329  speedup is 118.73
    [root@jumo-client tmp]# ll
    total 40
    -rwx------ 1  502  502 2272 Dec 12 11:32 ks-script-LRvD5O
    -rwxr-xr-x 1  502  502   66 Dec 12 11:32 ks-script-LRvD5O.log
    drwxr-xr-x 3  502  502 4096 Dec 17 07:24 linuxea
    -rw-r--r-- 1 root root    0 Dec 19 07:04 linuxea.txt
    drwx------ 2  502  502 4096 Dec 12 03:38 pulse-75mVmxEZuktI
    drwx------ 2  502  502 4096 Dec 12 03:39 pulse-phsa2Tvp17nZ
    drwx------ 2  502  502 4096 Dec 12 03:38 virtual-root.LmpRtk
    drwxr-xr-x 2  502  502 4096 Dec 12 11:34 vmware-config0
    drwxrwxrwt 2  502  502 4096 Dec 12 11:34 VMwareDnD
    drwx------ 2  502  502 4096 Dec 19 03:38 vmware-root
    drwx------ 2  502  502 4096 Dec 12 04:34 vmware-root-593009104
    -rw------- 1  502  502    0 Dec 12 11:27 yum.log

推送:本地有的文件远端比如有,本地没有的,删除远端独有的将本地tmp下的文件同步到backup下,tmp和backup保持一致

[root@jumo-client tmp]# touch 2.txt
[root@jumo-client tmp]# rsync -avz --delete /tmp/ rsync_backup@10.0.0.30::backup  --password-file=/etc/rsync.password
sending incremental file list
./
2.txt

sent 2384 bytes  received 41 bytes  692.86 bytes/sec
total size is 294329  speedup is 121.37
[root@jumo-client tmp]# 

在rysnc服务端查看,2.txt已经同步到rsyncsd端

[root@Rsync backup]# ll
total 40
-rw-r--r-- 1 rsync rsync    0 Dec 19 07:17 2.txt
-rwx------ 1 rsync rsync 2272 Dec 12 11:32 ks-script-LRvD5O
-rwxr-xr-x 1 rsync rsync   66 Dec 12 11:32 ks-script-LRvD5O.log
drwxr-xr-x 3 rsync rsync 4096 Dec 17 07:24 linuxea
-rw-r--r-- 1 root  root     0 Dec 19 07:04 linuxea.txt
drwx------ 2 rsync rsync 4096 Dec 12 03:38 pulse-75mVmxEZuktI
drwx------ 2 rsync rsync 4096 Dec 12 03:39 pulse-phsa2Tvp17nZ
drwx------ 2 rsync rsync 4096 Dec 12 03:38 virtual-root.LmpRtk
drwxr-xr-x 2 rsync rsync 4096 Dec 12 11:34 vmware-config0
drwxrwxrwt 2 rsync rsync 4096 Dec 12 11:34 VMwareDnD
drwx------ 2 rsync rsync 4096 Dec 19 03:38 vmware-root
drwx------ 2 rsync rsync 4096 Dec 12 04:34 vmware-root-593009104
-rw------- 1 rsync rsync    0 Dec 12 11:27 yum.log
[root@Rsync backup]# 

命令排除rsync命令排除:--exclude排除单个文件

rsync -avz --exclude=a /data1 rsync_backup@10.0.0.30::linuxea --password-file=/etc/rsync.password

[root@jumo-client tmp]# ls
10.pdf  2.txt  5.pdf  8.pdf             ks-script-LRvD5O.log  pulse-75mVmxEZuktI   vmware-config0  vmware-root-593009104
1.pdf   3.pdf  6.pdf  9.pdf             linuxea               pulse-phsa2Tvp17nZ   VMwareDnD       yum.log
2.pdf   4.pdf  7.pdf  ks-script-LRvD5O  linuxea.txt           virtual-root.LmpRtk  vmware-root
[root@jumo-client tmp]# rsync -avz --exclude=1.pdf /tmp/ rsync_backup@10.0.0.30::backup  --password-file=/etc/rsync.password
sending incremental file list
./
10.pdf
2.pdf
3.pdf
4.pdf
5.pdf
6.pdf
7.pdf
8.pdf
9.pdf

sent 2842 bytes  received 193 bytes  674.44 bytes/sec
total size is 294329  speedup is 96.98
[root@jumo-client tmp]# 

多个文件--exclude={a,b} ,也可以将排除的文件放在文件中--exclude-from=wenjian.log请输入图片描述

相关文章

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

发布评论