Linux system backup strategy discussion

  
 

Why should I back up the Linux system in an application? The Linux system is affected by the internal environment, the impact of the underlying hardware, and the attack by foreign hackers. It is inevitable that as a system administrator, its responsibility is not to It is impossible to ensure that the system will never have problems. In the event of a system failure or crash, the system can be restored in the shortest time and in the shortest time to ensure data security and bring faults. The loss is reduced to the lowest point. This requires system administrators to have a reasonable backup and recovery strategy for operating system
and business applications. A perfect backup strategy can guarantee zero downtime and complete data recovery. Since the service is running on the operating system
, the backup and recovery efficiency of the operating system
is directly related to the recovery of the entire business system. So the backup of the operating system
has become crucial. Second, the Linux system needs to back up the data. There is ghost software under Windows. The whole system can be completely copied to another hard disk. Ghost is a disk mirroring technology, which can mirror all data of the system disk to another backup hard disk. When the system appears Problem, with the backup mirror disk, all the data of the system can be completely recovered in a short time. Although there are tools similar to ghost in Linux, due to hardware compatibility, complexity of recovery, etc., ghost is not very good for Linux image backup, and if the Linux system disk partition is too large, the backup and recovery process will be very Long, so ghost is not suitable for backing up the Linux operating system. In fact, the full backup system is not a good strategy. The Linux operating system does not need to be fully backed up. We only need to back up all the configuration files of the system, so the backup process is fast and the recovery is fast. The files that Linux systems need to back up can be roughly divided into two categories: system-level configuration files and user-level configuration files. System-level configuration files are mainly configuration information of the system globally, such as /etc/directory, /home directory, /boot directory, /root directory, and so on. These directories are critical to the operation of the system and are different for different system applications. If these files are lost, even if the new operating system can be installed quickly, the system will be reconfigured and it will take longer. long. The user-level configuration file is the configuration file of the user's business application and system. These files are essential for running the system business application. Once lost, the system business cannot be started, for example, /usr/local entire directory, /var/www Directory, /etc entire directory, etc. Important files must be backed up, so what are the directories that do not need to be backed up, such as /dev directory, /proc directory, /mnt directory, /tmp directory, etc. These directories do not need to be backed up, because these directories are either It is memory data, either temporary files, no important data, the principle of backup is that important data must be backed up completely, and useless data is never backed up. Three backup media and methods To back up data, there must be a secure container for storing data. The basic requirements for storage media are generally considered in terms of access speed, storage security, and storage capacity. Access speed is a basic requirement for storage media. Data backup is a very frequent process of reading and writing operations. Backup media with very high access speed can greatly shorten the time for backing up data and reduce the time for data recovery. . Storage security is a hard requirement for storage media. Insecure storage devices are not as good as storage media. Many storage devices now do a lot of optimizations for security, such as doing raid disk arrays, cache reading and writing, and so on. Professional storage vendors include EMC, IBM, SUN, etc., all with their own storage devices. Storage capacity is also an aspect that must be considered when selecting a storage medium. Excessive storage space will result in waste of storage devices, too small storage space, resulting in data storage failure. Therefore, you must select the storage of the appropriate size according to the size of the backup data. medium. 1. Common storage media commonly used for backup media are optical drives, disks, tape drives, floppy disks, etc. Here, we will focus on the use of tape drives: There are several ways to use tape drives under Linux. The tar command is the most frequently used method. Used in a stand-alone environment to write data directly to the tape drive. The corresponding device name of the tape drive under Linux is /dev/stX. If it is the first tape drive, it is /dev/st0. The basic operation is as follows: (1) Rewind, roll the tape to the starting position mt -f /dev/st0 rewind(2) Erase the contents of the tape mt -f /dev/st0 erase The newly purchased tape can be used after being opened, no need to erase and write, and the tape can be overwritten when the data is full. The original data continues to be written, so there is no need to perform any erasing action. Since the erasing has certain damage to the tape, it is recommended not to perform the erasing operation. (3) tape, that is, the tape is rolled to the initial position and then ejected from the tape drive mt – f /dev/st0 offline (4) through tar listing the directory on the tape or file tar tvf /dev/st0 [need to view File or directory] If you do not follow any files or directories, you will view all the data on the tape. When there is no data on the tape, doing this will give an error, but it will not affect the tape usage. (5) Backing up data to tape by tar cvf /dev/st0 [name of file or directory to be written] There are two ways to back up data to tape, packaged and written to tape and not packaged directly to tape. Here we recommend the method of writing data directly to tape without packaging. This can improve the security of data storage. Why is it not recommended to pack backups? Because tapes are written sequentially, that is, linear storage. If all the data is packaged into a single file, failure of any part of the tape may cause the compressed file to be decompressed. Not available, and if the backup data is not packaged, there are many files on the tape. Even if the tape fails somewhere, the rest of the files are still available, which greatly improves the security of the data backup. For example, to write the compressed file /data/ixdba1.tar.gz to tape and overwrite the original content, you can do the following: [root@webserver /data]# tar cvf /dev/st0 /data/ixdba1. When tar.gz writes data to tape by <tar cvf”, it overwrites the original data in the tape each time, that is, each time the data is written from the beginning of the tape. The transfer speed of the tape drive is relatively slow. For a backup file that is not very large, it can be backed up in a short time, which is very suitable for system-level file backup. (6) Continue to write data to tape by tar rvf /dev/st0 [name of file to be written] Since the tape is linearly stored, the data is written sequentially, in order to not overwrite the original when writing new data With existing data, you can use the <quo;tar rvf” parameter combination to write data to the tape in turn. For example, back up /data/ixdba2.tar.gz and /data/ixdba3.tar.gz to the tape drive: [root@webserver /data]# tar rvf /dev/st0 /data/ixdba2.tar.gz [root @webserver /data]# tar rvf /dev/st0 /data/ixdba3.tar.gz (7)Recover data from tape to disk by tar xvf /dev/st0 [file or directory name to be restored] For example, first Review all the data that exists on the tape: [root@webserver ~]# tar tvf /dev/st0

Copyright © Windows knowledge All Rights Reserved