Skip to content

Commit ed66de5

Browse files
authored
Merge pull request #370 from sspencerwire/edit_364
Edit 364
2 parents 898458b + f47d16f commit ed66de5

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

docs/books/learning_rsync/01_rsync_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ What are the backup methods?
2323

2424
## rsync in brief
2525

26-
On a server, I backed up the first partition to the second partition, which is commonly known as "Local backup." The specific backup tools are `tar` , `dd` , `dump` , `cp `, etc. can be achieved. But you shouldn't "put all of your eggs in the same basket." Once the hardware fails and cannot start normally, the data still cannot be retrieved." In order to solve the local backup For this problem, we introduced another kind of backup --- "remote backup".
26+
On a server, I backed up the first partition to the second partition, which is commonly known as "Local backup." The specific backup tools are `tar` , `dd` , `dump` , `cp `, etc. can be achieved. But you shouldn't "put all of your eggs in the same basket." Once the hardware fails and cannot start normally, the data still cannot be retrieved. In order to solve the local backup For this problem, we introduced another kind of backup --- "remote backup".
2727

2828
Some people will say, can't I just use the `tar` or `cp` command on the first server and send it to the second server via `scp` or `sftp`?
2929

docs/books/learning_rsync/01_rsync_overview.zh.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ update: 2021-11-04
2222

2323
## rsync简述
2424

25-
在一台服务器上我将第一个分区备份到第二个分区,也就是俗称的 " 本地备份(Local backup)",备份的具体工具有`tar``dd``dump``cp`等都能实现。但其实还是 "把鸡蛋放在一个同篮子里(Don't put the eggs in the same basket)",一旦硬件出现问题然后无法正常的引导和启动,数据还是没办法找回,为了解决本地备份的这个问题,我们引入了另外一种备份————"异地备份"
25+
在一台服务器上我将第一个分区备份到第二个分区,也就是俗称的 " 本地备份(Local backup)",备份的具体工具有`tar``dd``dump``cp`等都能实现。但是 但是你不应该“把所有的鸡蛋放在同一个篮子里”。 一旦硬件出现故障无法正常启动,数据仍然无法检索。 为了解决本地备份这个问题,我们引入了另一种备份——“远程备份”
2626

2727
有人会说,我在第一台服务器上使用tar或者cp命令,然后通过scp或者sftp传到第二台服务器不就可以了吗?
2828

@@ -47,10 +47,13 @@ rsync就是为了满足以上的需求而出现的,使用GNU开源许可证协
4747
**rsync本身只是一个增量备份的工具,并不具备实时数据同步的功能,需要搭配另外的程序做功能补充。除了这之外,同步是单向的,要想双向备份,需要使用另外的工具才能实现。**
4848

4949
### 基本原理和特点
50+
5051
rsync是如何实现高效的单向数据同步备份的?
52+
5153
rsync的核心就是它的**Checksum算法**,如果您感兴趣可以去 [Rsync工作原理](https://rsync.samba.org/how-rsync-works.html) 以及 [rsync算法](https://rsync.samba.org/tech_report/) 了解,这一部分超出了作者的能力范围,不做过多的说明。
5254

5355
rsync的特点有:
56+
5457
* 能以递归的形式更新整个目录;
5558
* 能有选择的保留文件同步属性,比如硬链接、软链接、所有者、所属组、对应权限、修改时间等,可以保留其中的一部分属性;
5659
* 支持两种协议进行传输,一个是ssh协议,一个是rsync协议

docs/books/learning_rsync/02_rsync_demo01.zh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Fedora34-->|pull/下载|RockyLinux8;
6464
## 基于SSH协议的演示
6565

6666
!!! tip "注意!"
67-
这里Rocky Linux 8和 Fedora 34都使用 root 用户进行登录。Fodora 34是客户端,Rocky Linux 8是服务器。
67+
这里Rocky Linux 8和 Fedora 34都使用 root 用户进行登录。Fedora 34是客户端,Rocky Linux 8是服务器。
6868

6969
### pull/下载
7070

@@ -114,6 +114,7 @@ rsync error: some files/attrs were not transferred (see previous errors) (code 2
114114
```
115115

116116
**提示权限拒绝,如何处理?**
117+
117118
首先查看 /rsync/ 这个目录的权限。很明显没有w权限,我们可以使用`setfacl`赋予权限
118119

119120
```bash

docs/books/learning_rsync/03_rsync_demo02.zh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ update: 2021-11-04
99
在vsftpd中,有虚拟用户(管理员自定义的模拟用户),原因在于使用匿名用户和本地用户都不太安全。我们知道基于SSH协议的服务器必须要保证有一个系统的用户,当有许多的同步需求时,就可能需要创建许多的用户,这显然不符合GNU/Linux的运维标准(用户数越多,服务器越不安全),在rsync中,为了安全性考虑,就有了rsync协议验证登录方式。
1010

1111
**具体如何操作?**
12+
1213
在配置文件中写入对应的参数以及值就可以了。在Rocky Linux 8中,需要手动创建 <font color=red>/etc/rsyncd.conf</font> 这个文件。
1314

1415
```bash
@@ -28,7 +29,7 @@ update: 2021-11-04
2829
| comment = rsync | 备注或者描述信息 |
2930
| path = /rsync/ | 所在的系统路径位置 |
3031
| read only = yes| yes表示只读,no表示可读可写 |
31-
| dont compress = *.gz *.gz2 *.zip | 哪些文件类型不对它进行压缩 |
32+
| dont compress = \*.gz \*.gz2 \*.zip | 哪些文件类型不对它进行压缩 |
3233
| auth users = li| 启用虚拟用户,定义个虚拟用户叫什么。需要自行创建|
3334
| secrets file = /etc/rsyncd_users.db | 用来指定虚拟用户的密码文件位置,必须以.db结尾。文件的内容格式是"用户名:密码",一行一个 |
3435

docs/books/learning_rsync/07_rsync_unison_use.zh.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ update: 2021-11-06
1010

1111
## 环境准备
1212

13-
* Rocky Linix 8 与 Fedora 34 都需要源代码编译安装 **inotify-tools** ,这里不具体展开。
13+
* Rocky Linux 8 与 Fedora 34 都需要源代码编译安装 **inotify-tools** ,这里不具体展开。
1414
* 两台机器都必须免密登录验证,这里我们使用的是SSH协议进行
1515
* [ocaml](https://github.com/ocaml/ocaml/) 使用v4.12.0,[unison](https://github.com/bcpierce00/unison/) 使用v2.51.4。
1616

@@ -59,7 +59,7 @@ bin lib man
5959
...
6060
[root@Rocky /usr/local/src/unison-2.51.4]# ls src/unison
6161
src/unison
62-
[root@Rocky /usr/local/src/unison-2.51.4] cp -p src/unison /usr/local/bin
62+
[root@Rocky /usr/local/src/unison-2.51.4]# cp -p src/unison /usr/local/bin
6363
```
6464

6565
## Fedora 34 安装unison
@@ -86,7 +86,7 @@ bin lib man
8686
...
8787
[root@fedora /usr/local/src/unison-2.51.4]# ls src/unison
8888
src/unison
89-
[root@fedora /usr/local/src/unison-2.51.4] cp -p src/unison /usr/local/bin
89+
[root@fedora /usr/local/src/unison-2.51.4]# cp -p src/unison /usr/local/bin
9090
```
9191

9292

@@ -97,9 +97,9 @@ src/unison
9797
### 配置Rcoky Linux 8
9898

9999
```bash
100-
[root@Rocky ~] mkdir /dir1
101-
[root@Rocky ~] setfacl -m u:testrsync:rwx /dir1/
102-
[root@Rocky ~] vim /root/unison1.sh
100+
[root@Rocky ~]# mkdir /dir1
101+
[root@Rocky ~]# setfacl -m u:testrsync:rwx /dir1/
102+
[root@Rocky ~]# vim /root/unison1.sh
103103
#!/bin/bash
104104
a="/usr/local/inotify-tools/bin/inotifywait -mrq -e create,delete,modify,move /dir1/"
105105
b="/usr/local/bin/unison -batch /dir1/ ssh://[email protected]//dir2"
@@ -115,9 +115,9 @@ done
115115
### 配置Fedora 34
116116

117117
```bash
118-
[root@fedora ~] mkdir /dir2
119-
[root@fedora ~] setfacl -m u:testrsync:rwx /dir2/
120-
[root@fedora ~] vim /root/unison2.sh
118+
[root@fedora ~]# mkdir /dir2
119+
[root@fedora ~]# setfacl -m u:testrsync:rwx /dir2/
120+
[root@fedora ~]# vim /root/unison2.sh
121121
#!/bin/bash
122122
a="/usr/local/inotify-tools/bin/inotifywait -mrq -e create,delete,modify,move /dir2/"
123123
b="/usr/local/bin/unison -batch /dir2/ ssh://[email protected]//dir1"
@@ -139,4 +139,4 @@ done
139139
`[root@Rocky ~]# chmod +x /etc/rc.local`
140140

141141
!!! tip "注意!"
142-
如果您要停止这个脚本的对应进程,可以在 `htop` 命令中找到它然后 **kill** 即可
142+
如果您要停止这个脚本的对应进程,可以在 `htop` 命令中找到它然后 **kill** 即可

0 commit comments

Comments
 (0)