In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to achieve remote automatic backup under the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Considering that the data is backed up on this machine, once the hard disk of the machine fails, the data cannot be taken out. Backing up data manually remotely is time-consuming and untimely. The best way is to implement remote automatic backup through scripts. However, whether logging in via SSH or copying files through scp, you need to enter a password. To overcome this problem, you first need to implement a password-free SSH login so that you can use commands such as rsync,scp,rexec to make remote backups.
1. Set up a password-free ssh login as follows:
Suppose you need to log in to computer B with root on machine An instead of entering a password, then we can follow these steps:
1) generate a key pair on machine An and execute the following command:
Ssh-keygen-t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/ root/.ssh/id_rsa): / root/.ssh/id_rsa
Enter passphrase (empty for no passphrase): enter directly
Enter same passphrase again: enter directly
Your identification has been saved in / root/.ssh/id_rsa.
Your public key has been saved in / root/.ssh/id_rsa.pub.
The key fingerprint is:
F6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 root@host1
In this way, id_rsa and id_rsa.pub are generated under the / root/.ssh/ path, where id_rsa is the key and id_rsa.pub is the public key.
2) copy the id_rsa.pub generated on machine A to machine B, assuming that it is copied to the temporary directory of machine B, such as:
Scp / root/.ssh/id_rsa.pub root@218.242.214.20:/tmp
3) Log in to computer B with your root account, enter its home directory, create an authorized_keys file, and set permissions.
Cd / .ssh
Cat / tmp/id_rsa.pub > > authorized_keys
Chmod 400 authorized_keys
Rm-f / tmp/id_rsa.pub
4) Test
Go to the root account on machine An and try to log in to machine B. See if you don't want a password.
Description:
The permissions of the authorized_keys file are very important. If you set it to 777, you still need to provide a password when you log in.
Remember to delete the id_rsa.pub in the temporary directory and form a good habit.
This method has passed the test on Red Hat9.0.
two。 Edit the crontab file
Vi / etc/crontab
For example, the script in cron.daily is set to execute at 3:00 every morning:
00 3 * root run-parts / etc/cron.daily
3. Edit scripts in cron.daily
Cd / etc/cron.daily/
Vi backupdb
Pg_dump-U postgres voipack > / voipack.sql
Pg_dump-U postgres regserver > / regserver.sql
Tar-cvjf / aavm.tgz.bz2 / usr/local/aavm
Tar-cvjf / oracle.tgz.bz2 / var/oracle
Scp / voipack.sql root@218.242.214.20:/root/218.242.214.23_backup
Scp / regserver.sql root@218.242.214.20:/root/218.242.214.23_backup
Scp / aavm.tgz.bz2 root@218.242.214.20:/root/218.242.214.23_backup
Scp / oracle.tgz.bz2 root@218.242.214.20:/root/218.242.214.23_backup
Copy the backup files generated on 23 to the 218.242.214.20:/root/218.242.214.23_backup path
The same method can back up the data from the hypothetical B server to the A server and realize the mutual backup between the two computers.
This is the end of the content of "how to realize remote automatic backup under Linux system". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.