Data recovery method and device, electronic device, and computer-readable storage medium

By obtaining and executing unmarked operation statements in database backup and restoration, and combining historical data, the problem of complex and average database backup and recovery products in the prior art is solved, and efficient and simple data recovery is achieved.

CN114461445BActive Publication Date: 2025-04-04CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111581990.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2025-04-04
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

The existing database backup and recovery products are complex and difficult to use, and the data recovery effect is average.

Method used

By obtaining the data recovery node and the operation statements that are not marked thereafter, these operation statements are executed to determine the recovery data, and to restore the database in combination with the historical recovery data.

Benefits of technology

Simplifies the data recovery process, reduces hardware consumption, improves recovery efficiency, and makes data recovery easier to use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114461445B_ABST
    Figure CN114461445B_ABST
Patent Text Reader

Abstract

The present invention discloses a data recovery method and device, an electronic device, and a computer-readable storage medium. The data recovery method comprises: obtaining a data recovery node and an unmarked operation statement after the data recovery node; executing the unmarked operation statement to determine the first recovery data; obtaining the historical recovery data before the data recovery node; and using the first recovery data and the historical recovery data to recover the database. When recovering data, the present invention only needs to perform a full recovery of the historical recovery data once, and the remaining historical operation statements are executed in sequence. The data recovery process is simple and easy to use, and can greatly reduce hardware consumption and improve the overall recovery efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database backup and recovery, and in particular to a data recovery method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Nowadays, we are in an era of data explosion. Data is an asset, and its importance is self-evident. Therefore, how to protect this asset is also very important. In the actual production environment, the most common way to save data assets is to store them in the database to prevent various unpredictable problems such as data loss or disk damage. Backup is a common method, and the recovery operation that appears as a pair is also particularly necessary. However, the database backup and recovery products available on the market are complex and difficult to use, highly professional, and the data recovery effect is average. Summary of the invention

[0003] Therefore, the technical problem to be solved by the present invention is that database backup and recovery products are complex and difficult to use and the data recovery effect is average, so a data recovery method and device, electronic device, and computer-readable storage medium are provided.

[0004] According to a first aspect, an embodiment of the present invention discloses a data recovery method, which includes: obtaining a data recovery node and an unmarked operation statement after the data recovery node; executing the unmarked operation statement to determine first recovery data; obtaining historical recovery data before the data recovery node; and using the first recovery data and the historical recovery data to recover the database.

[0005] Optionally, obtaining the unmarked operation statements after the data recovery node includes: when data recovery is required, determining the operation statements after the data recovery node according to the data recovery node; and determining the unmarked operation statements according to the operation statements after the data recovery node.

[0006] Optionally, determining the unmarked operation statements based on the operation statements after the data recovery node includes: marking the operation statements when the operation statements are invalid statements; and determining the unmarked operation statements as the unmarked operation statements based on the marking status of the operation statements.

[0007] Optionally, the restoring the database by using the first restoration data and the historical restoration data includes: overwriting original data of the database by using the first restoration data and the historical restoration data, determining new database data, and realizing the restoration of the database.

[0008] Optionally, the data recovery method further includes: acquiring a data backup node; and storing the data before the data backup node in a preset information tree.

[0009] Optionally, storing the data before the data backup node in a preset information tree includes: parsing the data before the data backup node to determine the data manipulation language, data definition language and data control language of the data; and storing the data manipulation language, data definition language and data control language of the data in a preset information tree.

[0010] Optionally, obtaining the data recovery node and the unmarked operation statements after the data recovery node includes: selecting the data recovery node from the data backup node; and extracting the unmarked operation statements after the data recovery node from a preset information tree.

[0011] According to the second aspect, an embodiment of the present invention also discloses a data recovery device, which includes: a first acquisition module, used to acquire a data recovery node and unmarked operation statements after the data recovery node; a determination module, used to execute the unmarked operation statements to determine first recovery data; a second acquisition module, used to acquire historical recovery data before the data recovery node; and a recovery module, used to restore the database using the first recovery data and the historical recovery data.

[0012] According to the third aspect, an embodiment of the present invention also discloses an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the steps of the data recovery method as described in the first aspect or any optional implementation manner of the first aspect.

[0013] According to a fourth aspect, an embodiment of the present invention further discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data recovery method as described in the first aspect or any optional embodiment of the first aspect.

[0014] The technical solution of the present invention has the following advantages:

[0015] The data recovery method provided by the present invention obtains a data recovery node and an unmarked operation statement after the data recovery node, and then executes the unmarked operation statement to obtain first recovery data, and then obtains historical recovery data before the data recovery node, and the first recovery data and the historical recovery data constitute the total recovery data to recover the database. When recovering data, the present invention only needs to perform a full recovery of the historical recovery data once, and the rest of the historical operation statements are executed in sequence. The data recovery process is simple and easy to use, and can greatly reduce hardware consumption and improve the overall recovery efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 A schematic diagram of a flow chart of a data recovery method according to an embodiment of the present invention;

[0018] Figure 2 A schematic diagram of the structure of a backup and recovery operation device based on the memo mode in an embodiment of the present invention;

[0019] Figure 3 is a specific flow chart of the data recovery method in an embodiment of the present invention;

[0020] Figure 4 A program diagram of a data recovery program in an embodiment of the present invention;

[0021] Figure 5 Another specific flow chart of the data recovery method in the embodiment of the present invention;

[0022] Figure 6 A schematic diagram of the structure of a data recovery device in an embodiment of the present invention;

[0023] Figure 7 FIG. 4 is a specific example diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0026] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, it can also be the internal connection of two components, it can be a wireless connection, or it can be a wired connection. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0027] In the description of the present invention, it should be noted that the term "and / and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0028] The embodiment of the present invention discloses a data recovery method, such as Figure 3 As shown, the method comprises the following steps:

[0029] Step 101: obtain a data recovery node and unmarked operation statements after the data recovery node.

[0030] Furthermore, before restoring the database, the database will be backed up. By creating a backup task, when the creation is successful, the data backup program will immediately obtain the latest gtid (global transaction identifier) ​​from the log file, and then make a global backup at the gtid point, backing up all the data in the database before the gtid point, and then storing the corresponding backup data in the information tree preset based on the memo mode. The corresponding backup data is stored by storing the data manipulation language, data definition language and data control language of the data in the preset information tree. When the database needs to be restored, the data recovery node can be selected from the corresponding data backup node gtid, and the corresponding database operation statement can be extracted from the preset information tree.

[0031] Specifically, when data recovery is required, the operation statements after the data recovery node are determined according to the data recovery node, and then the operation statements after the data recovery node are filtered and marked. When the operation statement is an operation statement that needs to be skipped, that is, an invalid statement, the operation statement is marked. After all operation statements are filtered and marked, the unmarked operation statements after the data recovery node are obtained.

[0032] Step 102: execute the unmarked operation statement to determine first restored data.

[0033] Specifically, by executing all unmarked operation statements after the data recovery node, the first recovery data after the data recovery node is obtained.

[0034] For example, when the database encounters an exception, all captured states are displayed to the user, allowing the user to intuitively view the memo history, and then the user marks the operation statements that do not need to be executed. By starting the data recovery task, all unmarked operation statements are executed in sequence to achieve multiple incremental backups. When restoring data, the present invention only needs to perform a full recovery once, and the remaining historical operation statements are executed in sequence, which greatly reduces hardware consumption and improves the overall recovery efficiency.

[0035] Step 103, obtaining historical recovery data before the data recovery node.

[0036] Step 104: Restore the database using the first recovery data and the historical recovery data.

[0037] Specifically, after the data recovery node is determined, all historical recovery data that has been backed up before the data recovery node is obtained, and then the original data of the database is overwritten with the first recovery data and the historical recovery data to obtain new database data, thereby realizing the recovery of the database.

[0038] Exemplarily, as an optional embodiment of the present invention, Figure 2As shown, the present invention also provides a backup and recovery operation device based on the memo mode, which can capture the database state at a certain moment without destroying the normal data operation of the database, and save this state outside the database, that is, a memo, and then display all captured states on the display device corresponding to the backup task. The user selects one or more states as exclusion objects through marking, and the device restores the database state in sequence. The device mainly includes a data source management module, a storage management module, a backup task management module and a recovery task management module. Among them, the data source management module is used to manage the data source that needs to be backed up, the storage management module is used to manage the server and its directory for memo storage, the backup task management module is used to manage the start and stop of the backup task and the display of the database backup status, and the recovery task management module is used to manage the start and stop of the recovery task and the monitoring of the database recovery status.

[0039] Further, such as Figure 3 As shown, when performing data backup and recovery, the user can register the server as the memo storage in the storage management module, register the data source that needs to be backed up in the data source management module, and select the server and directory for backup file storage. After determining the server for memo storage and selecting the server and directory for backup file storage, the user starts to create a backup task. After the backup task is successfully created, the data backup program will immediately read the latest site gtid from the binary log file, record it as data backup node A, and perform a full backup of all data before data backup node A. The data manipulation language dml, data definition language ddl, and data control language dcl of the data before data backup node A are parsed and recorded in the information tree preset based on the memo mode, and displayed in real time in the form of a memo history on the display device corresponding to the backup task. When the database is in an abnormal state and data needs to be restored, such as Figure 4 Shown is a preview of the program interface. The user can intuitively view the historical data backed up in the memo in the program interface, find the invalid operation statements that need to be skipped, click the mark button in turn to mark them, and after marking, click the start recovery button, and all unmarked operation statements will be executed based on the full backup to achieve dynamic recovery of the database. In this way, the data backup and recovery operation based on the memo mode can achieve data recovery by operating the memo history, which is intuitive and easy to use. When the database is recovering data, by executing all the operation statements after the data backup node, the data backup and recovery has high reliability and good flexibility, and the recovery rate can reach 100%. When restoring data, the present invention only needs to perform a full recovery once, and the remaining historical operation statements are executed in sequence, which greatly reduces hardware consumption and improves the overall recovery efficiency. For the creation and management of memos, such as Figure 5As shown, the initiator creates a memo to record the internal state of the server database selected by the initiator at the current moment, and can use the memo to restore the internal state of the database. The memo is responsible for storing the internal state of the server database selected by the initiator, and can prevent other objects except the initiator from accessing the memo. The manager is mainly responsible for saving the content of the memo, but the manager cannot operate or check the content of the memo. This ensures that only the initiator can back up and restore data, and a dedicated manager stores and manages the content of the memo, protecting data more securely.

[0040] The embodiment of the present invention also discloses a data recovery device, such as Figure 6 As shown, the device comprises:

[0041] A first acquisition module 61 is used to acquire a data recovery node and an unmarked operation statement after the data recovery node. For details, refer to step 101.

[0042] A determination module 62, configured to execute the unmarked operation statement to determine the first restored data, for details, refer to step 102;

[0043] The second acquisition module 63 is used to acquire the historical recovery data before the data recovery node. For details, refer to step 103.

[0044] The recovery module 64 is used to recover the database using the first recovery data and the historical recovery data. For details, refer to step 104.

[0045] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, the electronic device includes: a processor 701 and a memory 702, wherein the processor 701 and the memory 702 can be connected via a bus or other means. Figure 7 In the example, the bus connection is used; the processor 701 may be a central processing unit (CPU). The processor 701 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.

[0046] The memory 702 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the data recovery method in the embodiment of the present invention. The processor 701 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 702, that is, implements the data recovery method in the above method embodiment.

[0047] The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the processor 701, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 702 may optionally include a memory remotely arranged relative to the processor 701, and these remote memories may be connected to the processor 701 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0048] The one or more modules are stored in the memory 702, and when executed by the processor 701, the following is performed: Figure 1-5 The data recovery method in the illustrated embodiment.

[0049] The specific details of the above data recovery system can be found in Figure 1-5 The corresponding related descriptions and effects in the illustrated embodiments can be understood and will not be repeated here.

[0050] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.

[0051] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A data recovery method, characterized in that: include: Acquire a data recovery node and an unmarked operation statement after the data recovery node; Executing the unmarked operation statement to determine first restored data; Obtaining historical recovery data before the data recovery node; Restoring the database using the first restoration data and the historical restoration data; The method further comprises: Obtain a data backup node; the data backup node is the latest location; Storing the data before the data backup node in a preset information tree; The storing the data before the data backup node into a preset information tree includes: Parsing the data before the data backup node to determine the data manipulation language, data definition language and data control language of the data; storing the data manipulation language, data definition language and data control language of the data in an information tree preset based on a memorandum mode; The obtaining of the data recovery node and the unmarked operation statement after the data recovery node includes: Selecting a data recovery node from the data backup nodes; Extract the unmarked operation statements after the data recovery node from the preset information tree.

2. The method according to claim 1, characterized in that: The unmarked operation statements after obtaining the data recovery node include: When data recovery is required, determining the operation statement after the data recovery node according to the data recovery node; According to the operation statement after the data recovery node, an unmarked operation statement is determined.

3. The method according to claim 2, characterized in that The step of determining the unmarked operation statements according to the operation statements after the data recovery node includes: When the operation statement is an invalid statement, marking the operation statement; According to the marking status of the operation statements, the unmarked operation statements are determined as unmarked operation statements.

4. The method according to claim 1, characterized in that: The restoring the database by using the first restoration data and the historical restoration data includes: The original data of the database is overwritten by using the first recovery data and the historical recovery data, new database data is determined, and the database is recovered.

5. A data recovery device, characterized in that: include: A first acquisition module, used for acquiring a data recovery node and an unmarked operation statement after the data recovery node; A determination module, configured to execute the unmarked operation statement to determine first restored data; A second acquisition module is used to acquire the historical recovery data before the data recovery node; A recovery module, used to recover the database using the first recovery data and the historical recovery data; The data recovery device is further used to obtain a data backup node; the data backup node is the latest location; the data before the data backup node is parsed to determine the data manipulation language, data definition language and data control language of the data; the data manipulation language, data definition language and data control language of the data are stored in an information tree preset based on a memorandum mode; The first acquisition module is specifically used to select a data recovery node from the data backup node; Extract the unmarked operation statements after the data recovery node from the preset information tree.

6. An electronic device, characterized in that: include: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the steps of any data recovery method as claimed in claims 1-4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of any data recovery method according to claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Data recovery method and device applied to a database

    CN109491834A