Backup and recovery (full backup, incremental backup, differential backup)

Preface

What is called a backup: copy the data to another location, if the original data is corrupted, lost, or other problems occur. The important data can be restored to prevent the work from being completely impossible due to data loss.

Storage media include mobile hard drives, CDs, and web drives. To develop the habit of backup, companies need to back up offsite.

1. Data to be backed up in Linux

/root/directory
/home/directory
/var/spool/mail/directory
/etc/directory
other directories

Detailed explanation:
Many important data of /root/ are stored in the home directory of /root/. Once the system crashes, the data inside is needed.

/home/ Ordinary user's home directory, many operations, such as setting up a file server, the file server upload location is generally the ordinary user's home directory, this directory also needs to be backed up at this time.

/var/spool/mail/ mail server, mail is stored here by default, this time you need to back up the mail directory

/etc/ Storage location of important configuration files. So this directory also needs to be backed up.

The bin directory, although this directory is very important for system startup, if it does not exist, system startup problems will occur, but when I reinstall a new system, the contents of this /bin/ directory are the same. Generally, it does not need to be modified, it does not need to be backed up.
If you consider it will also consider the log directory, it is possible to back up the log. Just back up important data. If the entire disk is backed up, it is fine, but it takes up too much hard disk space. If you have the resources, you can prepare a server that is exactly the same as your original computer, so that if the first server goes down, the second can be replaced immediately. In some important network topology diagrams, it is indeed necessary to do some real-time backups for some important nodes. Heartbeat monitoring is required. Once the main server goes down, the slave server can replace it.

1.1 Installation service data

apache needs to backup data

(1) Configuration file
(2) Home page directory
(3) Log file

Detailed explanation:
(1) Configuration file: Save some function changes here, if you don't want to configure it again, you need to save it.

(2) Home page directory: The entire website is in this directory, and all web directories need to be backed up. Once the server goes down, the website will not be at least not down. As long as you are building an apache, take these web pages back and you can use it.

(3) Log files: For apache, log files are still more important.

1.2 MySQL needs to backup data

Mysql installed by source package: mysql installed by /usr/local/mysql/data/
RPM package:/var/lib/mysql/

Once there is a problem with mysql, just install a MySQL environment of exactly the same version and copy this directory back, and all data will be restored.
If a mail service is built, the information of each mailbox and the mail in each mailbox user are important locations in the backup.

2. Backup Strategy

Full backup: Full backup means to back up all the data that needs to be backed up. Of course, a full backup can back up the entire hard disk, the entire partition or a specific directory.

Incremental backup: The complete data is backed up on the first day, and only the newly added data is backed up every day after that.

Differential backup: back up the complete data on the first day and back up the new data on the second day. On the third day, back up the data on the second and third days. On the fourth day, back up the second day to Data for the fourth day. And so on

Explain the advantages and disadvantages of the three backups:

  • Full backup: A full backup guarantees complete data and is the fastest and most convenient to restore. However, a full backup requires more hard disk space and takes longer. So consider whether it is worth doing a full backup. If it is an important server, it is possible to prepare a separate server. You can't wait for the server to crash, and the copy will be restored manually. Instead, it will automatically detect and the backup server will proceed directly, which is more rigorous than a full backup. It is heartbeat monitoring. A full backup consumes more system resources, if it is fully backed up every time. It may lead to greater server pressure and other problems, so this is a basic backup strategy. Generally, a full backup is performed once a day or a week.

  • Incremental backup: If you have the original data on the first day, you need to perform a full backup, but when the second day is backed up, you only need to back up the new data on the second day without backing up the original data. When backing up on the third day, the data of the first two days has been saved, only the new data of the third day needs to be backed up, and so on. Compared with the previous time, back up the newly generated data. It needs to be compressed after the backup. Compared with the previous backup, each backup has any new data.
    Incremental backup is best in theory, because each time the new data is divided, the original data is only backed up once, and it takes up the least hard disk space, but this type of recovery is more troublesome. Benefits: The amount of backup data is the least, and the storage space is the least. Disadvantages: recovery is more troublesome.

  • Differential backup: This is a compromise between full backup and incremental backup. Each time it backs up, it is compared with the first full backup. Compared with full backup, as the number of days of backup time increases, the amount of data to be backed up for the first time is less (that is, less full backup), which is more convenient to restore than incremental backup. A compromise strategy at this time. The benefits are limited.

In practice, full backup and incremental backup are used the most.

3. Summary

Full backup
Advantages: Full backup guarantees complete data, which is the fastest and most convenient to restore.
Disadvantage: It takes up too much hard disk space.

Incremental backup
Advantages: The amount of data to be backed up is the least, and the storage space is the least.
Disadvantages: It is troublesome to restore

Differential backup
Advantages: It occupies less storage space than full backup, and it is easier to restore than incremental backup. This is one such method.

Guess you like

Origin blog.csdn.net/weixin_46818279/article/details/108211124