After the database server is set up, the first thing we need to do is not to consider which MySQL-initiated programs should be run on the server that supports the database, but when the database is damaged, how to safely restore to the last normal state to maximize data losses
After the database server is set up, the first thing we need to do is not to consider which MySQL-initiated programs should be run on the server that supports the database, but when the database is damaged, how to safely restore to the last normal state to maximize data losses
I. Preface:
After the database server is set up, the first thing we need to do is not to consider which MySQL-initiated programs should be run on the server that supports the database, but when the database is damaged, how to safely restore to the last normal state, minimizing data loss.
In other words, just the establishment of a database server can only describe what it can do, and it does not mean what it can do stably. Disaster recovery efficiency and comprehensiveness are also a quasi-factor in system stability, especially for a server system.
This section describes the automatic database backup and restoration methods after the database is damaged. Here, we use mysqlhotcopy and define a Shell script to implement automatic database backup. In addition, the entire process of automatic data backup and data recovery is based on Shell.
Prerequisites for creating a database backup
[1] creating an automatic backup script
Here, in order to make the database backup and recovery meet our actual requirements, use a Shell script to automate the entire backup process.
[2] Run the automatic database backup script
[3] Let the database backup script run automatically every day
Test whether automatic backup works properly (Backup Recovery Method)
Here, we will introduce the recovery method after the problem occurs through the actual operation process.
[1] restoration method after database Deletion
First, create a database for testing.
Then, run the database backup script you just created to back up the database you just created for testing.
Next, we log on to the MySQL server again and delete the database test we just created to test whether the data recovery is successful.
Above, we simulate the database destruction process. Next, we will use the backup method to restore the database after it is damaged.
Then, log on to the MySQL server again to check whether the database has been successfully restored.
The preceding result indicates that after the database is deleted, the data is successfully restored to the status before the database is deleted.