You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/books/learning_rsync/01_rsync_overview.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,9 @@ What are the backup methods?
23
23
24
24
## rsync in brief
25
25
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 in fact, it is still "Don't put the eggs in the same basket." Once the hardware fails and cannot boot and 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".
27
27
28
-
Some people will say, I use the `tar` or `cp` command on the first server, and then transfer it to the second server via `scp` or `sftp`.
28
+
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`?
29
29
30
30
In a production environment, the amount of data is relatively large. First of all, `tar` or `cp` consumes a lot of time and occupies system performance. Transmission via `scp` or `sftp` also occupies a lot of network bandwidth, which is not allowed in the actual production environment. Secondly, these commands or tools need to be manually entered by the administrator and need to be combined with the crontab of the scheduled task. However, the time set by crontab is not easy to grasp, and the set time is too short. For example, if it is executed once every 1 minute, it may happen that the first script is not executed, and the second script is executed again; the set time has passed For example, if it is executed once every 5 hours, there may be data loss because the data is not backed up in time.
31
31
@@ -48,10 +48,13 @@ The original `rsync` was maintained by the Australian programmer <font color=red
48
48
**rsync itself is only an incremental backup tool and does not have the function of real-time data synchronization. It needs to be supplemented with another program. In addition to this, synchronization is one-way, and if you want two-way backup, you need to use another tool to achieve it. **
49
49
50
50
### Basic Principles and Features
51
+
51
52
How does `rsync` achieve efficient one-way data synchronization backup?
52
-
The core of `rsync` is its **Checksum algorithm** . If you are interested, you can go to [ Rsync Working Principle ](https://rsync.samba.org/how-rsync-works.html) and [ rsync Algorithm ](https ://rsync.samba.org/tech_report/) I understand that this part is beyond the scope of the author's ability, so I won't give too much explanation.
53
+
54
+
The core of `rsync` is its **Checksum algorithm**. If you are interested, you can go to [How Rsync works](https://rsync.samba.org/how-rsync-works.html) and [The rsync algorithm](https://rsync.samba.org/tech_report/) for more information, This section is beyond the author's competence and will not be covered too much.
53
55
54
56
The characteristics of `rsync` are:
57
+
55
58
* The entire directory can be updated recursively;
56
59
* Can selectively retain file synchronization attributes, such as hard link, soft link, owner, group, corresponding permissions, modification time, etc., and can retain some of the attributes;
57
60
* Support two protocols for transmission, one is ssh protocol, the other is rsync protocol
Copy file name to clipboardExpand all lines: docs/books/learning_rsync/02_rsync_demo01.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ update: 2021-11-04
15
15
Before the specific demonstration of rsync synchronization, you need to use the `rsync` command. In Rocky Linux 8, the rsync rpm package is installed by default, and the version is 3.1.3-12, as follows:
Copy file name to clipboardExpand all lines: docs/books/learning_rsync/03_rsync_demo02.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,16 @@ contributors: Steven Spencer
5
5
update: 2021-11-04
6
6
---
7
7
8
-
# Based on the presentation rsync protocol
8
+
# Demonstration based on rsync protocol
9
9
In vsftpd, there are virtual users (impersonated users customized by the administrator) because it is not safe to use anonymous users and local users. We know that a server based on the SSH protocol must ensure that there is a system of users. When there are many synchronization requirements, it may be necessary to create many users. This obviously does not meet the GNU/Linux operation and maintenance standards (the more users, the more insecure), in rsync, for security reasons, there is an rsync protocol authentication login method.
10
10
11
-
**How to do it? **
11
+
**How to do it?**
12
+
12
13
Just write the corresponding parameters and values in the configuration file. In Rocky Linux 8, you need to manually create the file <fontcolor=red>/etc/rsyncd.conf</font>.
13
14
14
15
```bash
15
-
[root@Rocky ~ ] # touch /etc/rsyncd.conf
16
-
[root@Rocky ~ ] # vim /etc/rsyncd.conf
16
+
[root@Rocky ~]# touch /etc/rsyncd.conf
17
+
[root@Rocky ~]# vim /etc/rsyncd.conf
17
18
```
18
19
19
20
Some parameters and values of this file are as follows, [ here ](04_rsync_configure.md) has more parameter descriptions:
@@ -28,7 +29,7 @@ Some parameters and values of this file are as follows, [ here ](04_rsync_
28
29
| comment = rsync | Remarks or description information |
29
30
| path = /rsync/ | The system path location where it is located |
30
31
| read only = yes| yes means read only, no means read and write |
31
-
| dont compress = *.gz *.gz2 *.zip | Which file types do not compress it |
32
+
| dont compress = \*.gz \*.gz2 \*.zip | Which file types do not compress it |
32
33
| auth users = li| Enable virtual users and define what a virtual user is called. Need to create it yourself|
33
34
| secrets file = /etc/rsyncd_users.db | Used to specify the location of the virtual user's password file, which must end in .db. The content format of the file is "Username: Password", one per line |
34
35
@@ -38,7 +39,7 @@ Some parameters and values of this file are as follows, [ here ](04_rsync_
38
39
Write some file content to <fontcolor=red>/etc/rsyncd.conf</font>, and write the user name and password to /etc/rsyncd_users.db, the permission is 600
@@ -119,7 +119,7 @@ rsync error: some files/attrs were not transferred (see previous errors) (code 2
119
119
Our virtual user here is <fontcolor=red>li</font>, which is mapped to the system user <fontcolor=red>nobody</font> by default. Of course, you can change it to other system users. In other words, nobody does not have write permission to the /rsync/ directory. Of course, we can use `[root@Rocky ~]# setfacl -mu:nobody:rwx /rsync/` , try again, and succeed.
Copy file name to clipboardExpand all lines: docs/books/learning_rsync/05_rsync_authentication-free_login.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ From [rsync Brief Description](01_rsync_overview.md) we know that rsync is an in
11
11
12
12
With inotify-tools, this program tool can realize one-way real-time synchronization. Since it is real-time data synchronization, the prerequisite is to log in without password authentication.
13
13
14
-
**Regardless of whether it is rsync protocol or SSH protocol, both can achieve password-free authentication login.**
14
+
**Regardless of whether it is rsync protocol or SSH protocol, both can achieve password-free authentication login.**
On the client side, the rsync service prepares an environment variable for the system-**RSYNC_PASSWORD**, which is empty by default, as shown below:
68
+
60
69
```bash
61
70
[root@fedora ~]# echo "$RSYNC_PASSWORD"
71
+
62
72
[root@fedora ~]#
63
73
```
74
+
64
75
If you want to achieve password-free authentication login, you only need to assign a value to this variable. The value assigned is the password previously set for the virtual user <font color=red>li</font>. At the same time, declare this variable as a global variable.
76
+
65
77
```bash
66
78
[root@Rocky ~]# cat /etc/rsyncd_users.db
67
79
li:13579
68
80
```
81
+
69
82
```bash
70
83
[root@fedora ~]# export RSYNC_PASSWORD=13579
71
84
```
85
+
72
86
Try it, success! No new files appear here, so the list of transferred files is not displayed.
Copy file name to clipboardExpand all lines: docs/books/learning_rsync/06_rsync_inotify.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,12 +28,12 @@ Append the environment variable PATH, write it to the configuration file and let
28
28
[root@Rocky ~]# vim /etc/profile
29
29
...
30
30
PATH=$PATH:/usr/local/inotify-tools/bin/
31
-
[root@Rocky ~]#. /etc/profile
31
+
[root@Rocky ~]#. /etc/profile
32
32
```
33
33
34
-
**Why not use the inotify-tools RPM package of the EPEL repository? And the way to use source code to compile and install?**
34
+
**Why not use the inotify-tools RPM package of the EPEL repository? And the way to use source code to compile and install?**
35
35
36
-
The author personally believes that remote data transmission is related to efficiency issues, especially in the production environment, when the number of files to be synchronized is large and the single file is particularly large, this is particularly important. In addition, the new version will have some bug fixes and function expansions, and perhaps the transmission efficiency of the new version will be higher, so I recommend installing inotify-tools by source code. Of course, this is the author's personal suggestion, not every user must follow.
36
+
The author personally believes that remote data transmission is a matter of efficiency, especially in a production environment, where there are a large number of files to be synchronized and a single file is particularly large. In addition, the new version will have some bug fixes and function expansions, and perhaps the transmission efficiency of the new version will be higher, so I recommend installing inotify-tools by source code. Of course, this is the author's personal suggestion, not every user must follow.
37
37
38
38
## Kernel parameter adjustment
39
39
@@ -46,6 +46,7 @@ You can adjust the kernel parameters according to the needs of the production en
When using the SSH protocol for data synchronization transmission, if the SSH service port of the target machine is not 22, you can use a method similar to this——
0 commit comments