In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to make automatic backup of Linux. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
1. Tool used: rsync,ssh
two。 Features:
L check the original file and copy only the changed blocks
L encrypt data using ssh
L allow pre-transmission compression
L when data is removed from the source system, it is automatically removed on the target system
L allows you to set the data transfer speed for WAN connections
L has the ability to copy device files
3. A simple backup diagram
Figure 1: backup diagram
4. Ssh server and client settings in order to achieve automatic two-way authentication, we use public key authentication. Here, we use root to connect to the server. First, change the ssh service configuration file / etc/ssh/sshd_config of the ssh server.
As shown below: remove the previous comments in the ellipse:
Figure 2
Then restart the service: # service sshd restart.
Generate key pairs for root users on the customer server:
# ssh-keygen-t rsa
As shown in figure 3, the id_rsa,id_rsa.pub file will be generated under the .ssh / directory in the home directory, where the first is the private key and the latter is the public key
Figure 3
Copy the contents of the public key id_rsa.pub to the / root/.ssh/authorized.keys file on the ssh server.
In this way, the server can authenticate the root user through the public key, while the client authenticates the server when it connects, automatically downloads the server public key from the server and puts it in ~ / .ssh/known_hosts.
* step: run the # ssh-add command
Then test:
On the customer service side, enter:
# ssh cluster2 hostname
Command, if successful, will directly output the results of the hostname run without prompting for a password.
5. Configure rsync:
Let's create a test directory on the rsync master server (ssh client):
# mkdir / www
# echo "this is a rsync test" > / www/index.html
Run the rsync command:
# rsync-v-a-z-e ssh-- delete / www/ cluster2:/www
-v display operation information
-a files and directories under the directory
-z compression
-e ssh is transmitted over ssh
/ www/ source directory, note that the backup destination is followed by "/". For detailed rsync options, please consult the online documentation to "pull" the remote files locally, just swap the source path with the destination path.
6. The rest is to copy backups on a regular basis through cron jobs. As follows
# crontab-e
30 * rsync-v-a-z-e ssh-- delete / www/ cluster2:/www > / dev/null 2 > & 1
This automatically synchronizes every 30 minutes.
After reading the above, do you have any further understanding of how Linux can be backed up automatically? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.