Linuxrsync + ssh Image Backup

Source: Internet
Author: User
A linux server in the company is really unreassuring, so it is afraid of the evening of which the thunderstorm is over. it is vulnerable and goes down & hellip; no way, limited resources, I had to contribute my usual office computer as an image backup service. The office computer is installed with a linux server of windowXP and centos5 dual-series Company. it is really reassuring that it will be afraid of which night of the thunderstorm, and it will be vulnerable to downtime... No way, limited resources, so I had to contribute my usual office computer as an image backup service. The office computer is equipped with Windows XP and centos5 dual systems, 1 TB hard drive. In linux, GB hard disk space is allocated for backup. (Alas, it's so bitter that the news of applying for a new computer is also overwhelming .) Let's get down to the truth. Actual environment: two centos5 servers for data synchronization and backup. Backup mode: rsync + ssh (because this is the simplest backup mode, and rsync backup speed is very low, not only can backup files, together with file attributes, owners, organizations and other information can be backed up in detail, and each backup only detects the updated part. Therefore, rsync is the best backup method for me .) Software Installation: rsync, ssh, which is usually installed by default, can be used directly. As for rsync, it is installed on its own. Linux dependency is really annoying, so decided to use the source package compilation and installation,: http://www.rsync.samba.org download decompress after completion, enter the directory after decompression, directly according to configure, make, make install trilogy. (Do not forget to install GCC ). The following is the practice process: assume that the master server IP address is 192.169.10.100, and the backup server IP address is 192.168.10.110. now the rsync software is installed on the master server and backup server. After installation: 1. install the ssh key on the backup server (used to log on to the target server without a password). here, I use the slave account to synchronize images (which account is used to synchronize data, which account is used to create the key ). # Ssh-keygen-t rsa <= This step produces Key pair
Generating public/private rsa key pair. enter file in which to save the key (/home/test2 /. ssh/id_rsa): <= Press EnterEnter passphrase (empty for no passphrase): <= Press EnterEnter same passphrase again here: <= Press EnterYour identification has been saved in/home/test2 /. ssh/id_rsa. <= This is the private key Your public key has been saved in/home/test2 /. ssh/id_rsa.pub. <= This is The public key, The key fingerprint is :*********************
# Note:-t refers to "what password calculation method is used ?』 Because we use RSA, # directly input-t rsa to create two Keys! # In addition, the created two Keys are all placed in the. ssh directory under the home directory! # Check the two Keys. $ ll ~ /. Ssh-rw ------- 1 test2 test2 887 Nov 12 id_rsa-rw-r -- r -- 1 test2 test2 233 Nov 12 id_rsa.pub-rw-r -- r -- 1 test2 test2 222 Oct 31 known_hosts above appears know_hosts, it is the first time you log on to the target server using ssh, you need to enter yes. after the input, you will have this stuff. For the second time, you do not need to enter "yes". simply enter the password. After the key is created and the password is not entered, you can directly log on to the remote server. *. Pub is the public key. Copy the file to the. ssh folder in the home directory of the master user of the master server. Rename it authorized_keys. if multiple clients need to be connected, use cat id_rsa.pub> authorized_keys to append the public key information to the authorized_keys file. Next, you can try password-free login. $ Ssh master@192.168.10.100 press enter is not directly in? -> (I was depressed for one night. at that time, there was no network cable at home, and I was not able to solve the problem after reading some references. the reason was that I used a virtual machine connected to the CRT software to perform experiments, you can import the key to the CRT before entering the password. It is estimated that the same is true for putty .) After the appeal is successful, you can use the slave account to synchronize the information of the master account (as long as the master has the permission to synchronize ). Enter the command: rsync-av-e ssh master@192.168.10.100:/home to synchronize contents under the master server/home to the/home directory of the local machine. Here, you can make an experiment about the/problem behind the path, for example,/home. Rsync syntax; [root @ linux ~] # Rsync [-avrlptgoD] [-e ssh] [user @ host:/dir] [/local/path] parameter:-v: observation mode. More information can be listed; -q: opposite to-v, quiet mode, less output information;-r: progressive replication! You can handle the "directory! Very important! -U: update only. it does not overwrite the target new file.-l: Copy the attributes of the link file, not the original object content of the link.-p: during replication, attributes (permission) remain unchanged! -G: Owner Group for saving the original file;-o: Owner for saving the original file;-D: device property for saving the original file) -t: the time parameter for saving the original file.-I: ignore the attribute of the update time (mtime). The File comparison is faster.-z: add the compression parameter! -E: The Channel Protocol used. for example, if you use an ssh channel,-e ssh-a: is equivalent to-rlptgoD. Therefore,-a is the most common parameter! For more instructions, see man rsync! In this way, my goal is achieved. I can synchronize data, write a small script, put it in crontab, and switch to the linux system every day after work. When I come in the morning, check if the synchronization is successful. Switch to window xp. That's it. In fact, this backup is not good, especially when the system is busy. In addition, the backup server does not do anything, power consumption does not say, a waste of resources. The backup server cannot work because the master server is down. Can only reduce losses

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.