Data recovery method and device, equipment, storage medium and computer program product

By saving the historical version data of PostgreSQL database to the message queue, and processing data recovery requests asynchronously, solving the problems of data recovery in the existing technology, which is long-term, high risk of failure and business interruption, and achieving fast, secure and no business impact data recover.

CN119440916APending Publication Date: 2025-02-14PEOPLE'S INSURANCE COMPANY OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411524982.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The data recovery method of the existing PostgreSQL database has the problem that data recovery takes a long time, has the risk of failure, and requires the shutdown of normal business services.

Method used

By obtaining the database history version data and saving it in the message queue, the data recovery request is processed asynchronously, finding the matching target history version data and performing database recovery.

Benefits of technology

It realizes rapid and efficient data recovery without affecting the normal operation of the database, reducing the risk of recovery failure and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440916A_ABST
    Figure CN119440916A_ABST
Patent Text Reader

Abstract

The invention discloses a data recovery method. The data recovery method is used for solving the problems that an existing data recovery method for a PostgreSQL database is long in data recovery time consumption, failure risks exist, and normal business services need to be shut down. The method comprises the steps of obtaining database historical version data; storing the historical version data in a message queue; according to a received data recovery request, determining to-be-recovered data information corresponding to the data recovery request; searching target historical version data matched with the to-be-recovered data information in the message queue; and performing data recovery on the database according to the target historical version data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data recovery method, apparatus, device, storage medium and computer program product. Background Art

[0002] PostgreSQL is a very powerful, open-source client / server relational database management system. In recent years, it has been favored by large, medium and small enterprises and used as a persistence layer solution for Internet products.

[0003] When using the PostgreSQL database, human error often occurs, resulting in data loss and other problems. To address the above problems, the traditional approach is to use pre-made data backups to perform database recovery. For example, timeline-based recovery can be performed based on pre-prepared physical backups and logical backups. However, the problems with this database recovery method are:

[0004] First, the data recovery process often requires stopping normal business services, which greatly affects the user experience.

[0005] Second, the data recovery time is too long. Taking a 10TB database as an example, considering factors such as restoring the full backup + additional backup + archive logs, the data recovery process may take more than 15 hours.

[0006] Third, there is a risk of recovery failure. The backed-up data may not be recoverable due to hardware factors such as the backup media.

[0007] It can be seen from this that how to realize the recovery of PostgreSQL database misoperation without stopping normal business services and overcome the shortcomings and limitations of PostgreSQL database misoperation recovery have become technical problems that need to be solved urgently. Summary of the invention

[0008] The embodiment of the present application provides a data recovery method to solve the problems of the existing data recovery method for PostgreSQL database, that is, data recovery takes a long time, there is a risk of failure, and normal business services need to be shut down.

[0009] The embodiment of the present application also provides a data recovery device to solve the problems of the existing data recovery method for the PostgreSQL database, such as long data recovery time, risk of failure and need to shut down normal business services.

[0010] The embodiment of the present application also provides a data recovery device to solve the problems of the existing data recovery method for the PostgreSQL database, such as the data recovery takes a long time, there is a risk of failure, and the normal business services need to be shut down.

[0011] The embodiment of the present application also provides a computer-readable storage medium to solve the problems of existing data recovery methods for PostgreSQL databases, such as long data recovery time, risk of failure, and need to shut down normal business services.

[0012] The embodiment of the present application also provides a computer program product to solve the problems of existing data recovery methods for PostgreSQL databases, such as long data recovery time, risk of failure, and need to shut down normal business services.

[0013] The present application embodiment adopts the following technical solutions:

[0014] A data recovery method comprises: obtaining historical version data of a database; saving the historical version data in a message queue; determining, based on a received data recovery request, data information to be recovered corresponding to the data recovery request; searching the message queue for target historical version data that matches the data information to be recovered; and recovering data in the database based on the target historical version data.

[0015] A data recovery device comprises: a data acquisition unit for acquiring historical version data of a database; a message queue storage unit for storing the historical version data in a message queue; a data information determination unit for determining the data information to be recovered corresponding to a data recovery request based on a received data recovery request; a target data determination unit for searching the message queue for target historical version data matching the data information to be recovered; and a data recovery unit for recovering data from the database based on the target historical version data.

[0016] A data recovery device, comprising:

[0017] A processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the following operations: obtain historical version data of a database; save the historical version data to a message queue; determine, based on a received data recovery request, data information to be recovered corresponding to the data recovery request; search the message queue for target historical version data that matches the data information to be recovered; and perform data recovery on the database based on the target historical version data.

[0018] A computer-readable storage medium stores one or more programs, which, when executed by an electronic device including multiple application programs, enable the electronic device to perform the following operations: obtain historical version data of a database; save the historical version data in a message queue; determine, based on a received data recovery request, data information to be recovered corresponding to the data recovery request; search the message queue for target historical version data that matches the data information to be recovered; and recover data in the database based on the target historical version data.

[0019] A computer program product comprises a computer program, which, when executed by a processor, implements the following steps: obtaining historical version data of a database; saving the historical version data in a message queue; determining, based on a received data recovery request, data information to be recovered corresponding to the data recovery request; searching the message queue for target historical version data that matches the data information to be recovered; and recovering data in the database based on the target historical version data.

[0020] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0021] By adopting the data recovery method provided by the embodiment of the present application, before the database responds to the database operation instruction and executes the corresponding data operation (for example, data deletion or data update), the historical version data before executing the database operation instruction can be obtained, and the historical version data can be sent to the message queue for storage. When a data recovery request is received later, the data information to be recovered corresponding to the data recovery request can be determined, and then the target historical version data matching the data information to be recovered is searched in the message queue, and the data recovery of the database is completed according to the target historical version data. By adopting the method provided by the embodiment of the present application, since the operation on the message queue and the operation of the database can be performed asynchronously, by saving the historical version data in the message queue, and when data recovery is required, the corresponding target historical version data is obtained from the message queue, and a database update statement is generated according to the obtained target historical version data, and then the database update statement is used to update and replace the existing data values ​​in the database according to the database update method, thereby realizing the recovery of the historical version data, greatly improving the data recovery efficiency, and the entire data recovery process will not affect the normal operation of the database, improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0023] Figure 1 A specific flow chart of a data recovery method provided in an embodiment of the present application;

[0024] Figure 2 A schematic diagram of the specific structure of a data recovery device provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of the specific structure of a data recovery device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0027] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0028] A data recovery method provided in an embodiment of the present application is used to solve the problems of existing data recovery methods for PostgreSQL databases, such as long data recovery time, risk of failure, and need to shut down normal business services.

[0029] The executor of the data recovery method provided in the embodiment of the present application may be, but is not limited to, at least one of a database management server, a database operation and maintenance server, a data recovery server or a database server; in addition, the executor of the method may also be an application (Application, APP) running on these servers or the system itself.

[0030] For ease of description, the following takes the execution subject of the method as a data recovery system set on a PostgreSQL database as an example to introduce the implementation of the method. It can be understood that the execution subject of the method as a data recovery system on a PostgreSQL database is only an exemplary description and should not be understood as a limitation of the method.

[0031] The specific implementation flow chart of the data recovery method provided in this application is as follows Figure 1 As shown, it mainly includes the following steps:

[0032] Step 11, obtaining historical version data of the database;

[0033] The historical version data is data that has been replaced by new data in an update or delete operation that has been executed.

[0034] Taking PostgreSQL database as an example, PostgreSQL database handles concurrency control based on Multi-Version Concurrency Control (MVCC) mechanism, which allows multiple transactions to safely access PostgreSQL database concurrently. Under the MVCC mechanism, when data rows are updated or deleted, they are not physically deleted immediately, but marked as "dead" in the data table (this type of data marked as "dead" can be called dead tuples), and the space occupied is marked as reusable. In the embodiment of the present application, these dead tuples in the data table are historical version data.

[0035] In an embodiment of the present application, the historical version data corresponding to the database can be obtained specifically according to the following method, including: receiving database operation instructions, wherein the database operation instructions include: data addition instructions, data deletion instructions and data update instructions; obtaining the historical version data of the database before executing the database operation instructions.

[0036] It should be noted that the database operation instruction may be triggered by a user, such as the user updating, deleting or adding data stored in the database according to business needs. In addition, the database operation instruction may also be triggered by a specific process (such as a daemon process or a cleanup process, etc.) in the database.

[0037] Still taking the PostgreSQL database as an example, under the MVCC mechanism, in order to maintain the performance and health of the database, the PostgreSQL database will regularly clean up the dead tuples in the database through AutoVacuum. AutoVacuum consists of a daemon process (AutoVacuum Launcher) and multiple worker processes (AutoVacuum Worker). The Launcher process is responsible for periodically checking whether the database table needs to be cleaned up, especially for those tables with a large number of insert, update or delete operations. When the number of dead tuples in the table exceeds a certain threshold, the Launcher process will trigger the database operation instruction to start the AutoVacuum Worker process to perform the actual cleaning and analysis tasks. In an embodiment of the present application, before the AutoVacuum process cleans up the dead tuples in the data table, the data recovery system can obtain the dead tuples in the data table and use these dead tuples as historical version data.

[0038] Step 12, saving the historical version data obtained by executing step 11 into the message queue;

[0039] In the embodiment of the present application, the data recovery system can specifically save the acquired historical version data to the message queue according to the following method, which can specifically include the following sub-steps:

[0040] Sub-step 1201, creating a message topic corresponding to each data table in a message queue according to the data tables included in the database;

[0041] In a database, instance, database, and table are the three basic organizational units. Instance is the top-level unit in a database. An instance can contain one or more databases. The database is located under the instance. An instance can contain multiple databases, but a database can only belong to one instance. The database is a logical container for storing data, which consists of a group of tables. The table is located under the library. A library can contain multiple tables. The table is the basic structure for storing data in the library, which consists of rows (records) and columns (fields).

[0042] In this case, the data recovery system can generate a corresponding message topic for each data table under each instance based on the instances, libraries and data tables corresponding to the database, and determine the label corresponding to the message topic according to the level of the data table corresponding to each message topic in the database (that is, which library under which instance the data table belongs to). For example, the label for the message topic can be generated according to the instance name + library name + data table name, and then subsequently, according to the correspondence between the acquired historical version data and the label of the message topic, it can be determined in which message topic of the message queue the historical version data needs to be stored.

[0043] It should also be noted that in the embodiments of the present application, the applicable message queue may be Kafka, RabbitMQ, RocketMQ or ActiveMQ, etc. The embodiments of the present application do not limit the specific message queue to be used.

[0044] Sub-step 1202, determining storage information corresponding to historical version data;

[0045] Among them, the storage information includes the storage level corresponding to the historical version data in the database, that is, the instance name, library name and data table name corresponding to the historical version data, so that when the historical version data is subsequently stored in the message queue, the corresponding message topic topic can be matched in the message queue according to the storage information.

[0046] Sub-step 1203, determining, based on the stored information, a first message topic that matches the historical version data in the message queue;

[0047] For example, the storage information corresponding to the historical version data obtained by the data recovery system is: instance A-library 1-table 14, then the data recovery system can search for the message topic with the label "instance A-library 1-table 14" in the message queue.

[0048] Sub-step 1205, saving the historical version data to the first message topic.

[0049] After executing the above sub-steps to store the historical version data into the corresponding message topic in the message queue, the message topic can save the received historical version data through a data table. For example, in an embodiment of the present application, the message topic can save the received historical version data in a data table as shown in Table 1.

[0050] Table 1 Historical version data storage table

[0051]

[0052]

[0053] In Table 1, "inserttime" indicates the date and time when the historical version data is inserted into the data table in the database, that is, the time when the historical version data is first written to the database, and the deletion time indicates the time when the historical version data is deleted from the database by AutoVacuum.

[0054] Step 13, determining the to-be-recovered data information corresponding to the data recovery request according to the received data recovery request;

[0055] In the embodiment of the present application, the data information to be restored may include but is not limited to the following information:

[0056] 1. Storage information corresponding to the data to be recovered;

[0057] That is, the data of which data table in which library in which instance of the database needs to be restored. In the embodiment of the present application, the storage information can generally be in the form of "instance name + library name + data table name".

[0058] 2. Data recovery scope;

[0059] The data recovery scope includes: the entire data table or part of the data table.

[0060] 3. Data recovery time;

[0061] That is, to which historical time the user wants to restore the data in the database.

[0062] Assume that the data recovery request received by the data recovery system contains the following information: "Restore the data with id 1 in the data source instance postgres library postgresdb data table usertab to: DateTime1 (2023-05-23 16:00:00)", then the data recovery system can determine that the storage information corresponding to the data to be recovered is: "instance postgres-library postgresdb-data table usertab", the data recovery range is the single data with id 1 in the "instance postgres-library postgresdb-data table usertab", and the data recovery time is 2023-05-23 16:00:00.

[0063] Assuming that the data recovery request received by the data recovery system contains the following information: "Restore the data in the data source instance postgres library postgresdb data table usertab to: DateTime1 (2023-05-23 16:00:00)", the data recovery system can determine that the storage information corresponding to the data to be recovered is: "instance postgres-library postgresdb-data table usertab", the data recovery range is the entire table data of "instance postgres-library postgresdb-data table usertab", and the data recovery time is 2023-05-2316:00:00.

[0064] Step 14, searching the message queue for target historical version data that matches the data information to be restored determined by executing the above step 13;

[0065] In an embodiment of the present application, the data recovery system may search the message queue for the target historical version data corresponding to the data recovery request according to the following sub-steps, including:

[0066] Sub-step 1401, searching the message queue for a second message topic that matches the storage information corresponding to the data to be restored;

[0067] Specifically, the data recovery system may search for a second message topic that matches the storage information corresponding to the data to be recovered based on the storage information in the data information to be recovered and the labels of each message topic in the message queue.

[0068] Sub-step 1402, determining candidate historical version data matching the data recovery moment in the second message topic;

[0069] In an embodiment of the present application, the data recovery system can match the historical version data whose "inserttime" is less than the data recovery time and closest to the data recovery time in the second message topic according to the data recovery time in the data information to be recovered and the "inserttime" corresponding to each historical version data in the second message topic, as candidate historical version data.

[0070] Sub-step 1403, determining a data recovery range according to the data information to be recovered, wherein the data recovery range includes: the entire data table or a part of the data table;

[0071] Sub-step 1404 , determining target historical version data from the candidate historical version data according to the data recovery scope.

[0072] For example, still taking the data recovery request received by the data recovery system containing the following information: "Restore the data with id 1 in the postgresdb data table usertab of the data source instance postgres library to: DateTime1 (2023-05-23 16:00:00)" as an example, assuming that the historical version data related to id=1 stored in the message topic topic identified as "postgres-postgresdb-usertab" in the message queue is shown in Table 2 below, then through matching, it can be determined that the data corresponding to version V2 in Table 2 is the data that needs to be restored for this data recovery request.

[0073] Table 2 Historical version data storage table

[0074]

[0075] Step 15: Restore the database based on the target historical version data.

[0076] In an embodiment of the present application, the data recovery system can generate a data update statement based on the target historical version data and the data table structure, and update the data table corresponding to the data recovery request based on the data update statement to complete the data recovery of the data.

[0077] By adopting the data recovery method provided by the embodiment of the present application, before the database responds to the database operation instruction and executes the corresponding data operation (for example, data deletion or data update), the historical version data before executing the database operation instruction can be obtained, and the historical version data can be sent to the message queue for storage. When a data recovery request is received later, the data information to be recovered corresponding to the data recovery request can be determined, and then the target historical version data matching the data information to be recovered is searched in the message queue, and the data recovery of the database is completed according to the target historical version data. By adopting the method provided by the embodiment of the present application, since the operation on the message queue and the operation of the database can be performed asynchronously, by saving the historical version data in the message queue, and when data recovery is required, the corresponding target historical version data is obtained from the message queue, and a database update statement is generated according to the obtained target historical version data, and then the database update statement is used to update and replace the existing data values ​​in the database according to the database update method, thereby realizing the recovery of the historical version data, greatly improving the data recovery efficiency, and the entire data recovery process will not affect the normal operation of the database, improving the user experience.

[0078] In one embodiment, the present application also provides a data recovery device to solve the problems of the existing data recovery method for PostgreSQL database, such as long data recovery time, risk of failure, and need to shut down normal business services. Figure 2 As shown, it includes: a data acquisition unit 21, a message queue storage unit 22, a to-be-recovered data information determination unit 23, a target data determination unit 24 and a data recovery unit 25.

[0079] Wherein, the data acquisition unit 21 is used to acquire the historical version data of the database;

[0080] A message queue storage unit 22, used to store the historical version data in a message queue;

[0081] The to-be-restored data information determining unit 23 is configured to determine, according to the received data recovery request, the to-be-restored data information corresponding to the data recovery request;

[0082] A target data determination unit 24 is used to search the message queue for target historical version data that matches the data information to be restored;

[0083] The data recovery unit 25 is used to recover the data of the database according to the target historical version data.

[0084] In one embodiment, the data acquisition unit 21 is specifically used to: receive database operation instructions, wherein the database operation instructions include: data addition instructions, data deletion instructions and data update instructions; and obtain historical version data of the database before executing the database operation instructions.

[0085] In one embodiment, the message queue saving unit 22 is specifically used to: create a message topic corresponding to each data table in the message queue according to the data tables contained in the database; determine the storage information corresponding to the historical version data, wherein the storage information includes the instance name, library name and data table name of the historical version data stored in the database; determine the first message topic that matches the historical version data in the message queue according to the storage information; and save the historical version data in the first message topic.

[0086] In one embodiment, the data information to be recovered includes storage information corresponding to the data to be recovered, a data recovery range, and a data recovery time. The target data determination unit 24 is specifically used to: search the message queue for a second message topic that matches the storage information corresponding to the data to be recovered; determine candidate historical version data that matches the data recovery time in the second message topic; determine the data recovery range based on the data information to be recovered, wherein the data recovery range includes: the entire data table or a portion of the data table; and determine the target historical version data from the candidate historical version data based on the data recovery range.

[0087] In one embodiment, the data recovery unit 25 is specifically used to: generate a data update statement according to the target historical version data and the data table structure; and update the data table corresponding to the data recovery request according to the data update statement to complete the data recovery of the data.

[0088] By adopting the data recovery device provided by the embodiment of the present application, before the database responds to the database operation instruction and executes the corresponding data operation (for example, data deletion or data update), the historical version data before executing the database operation instruction can be obtained, and the historical version data can be sent to the message queue for storage. When a data recovery request is received later, the data information to be recovered corresponding to the data recovery request can be determined, and then the target historical version data matching the data information to be recovered is searched in the message queue, and the data recovery of the database is completed according to the target historical version data. By adopting the method provided by the embodiment of the present application, since the operation on the message queue and the operation of the database can be performed asynchronously, the historical version data is saved in the message queue, and when data recovery is required, the corresponding target historical version data is obtained from the message queue, and a database update statement is generated according to the obtained target historical version data, and then the database update statement is used to update and replace the existing data values ​​in the database according to the database update method, thereby realizing the recovery of the historical version data, greatly improving the data recovery efficiency, and the entire data recovery process will not affect the normal operation of the database, improving the user experience.

[0089] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 3At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0090] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0091] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0092] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data recovery device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: obtain the network feature data to be analyzed; obtain the historical version data of the database; save the historical version data to the message queue; determine the data information to be recovered corresponding to the data recovery request according to the received data recovery request; search the target historical version data matching the data information to be recovered in the message queue; and recover the data of the database according to the target historical version data.

[0093] The above application Figure 3The method performed by the data recovery electronic device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0094] Of course, in addition to software implementation, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0095] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:

[0096] Obtain historical version data of a database; save the historical version data in a message queue; determine the data information to be recovered corresponding to the data recovery request based on the received data recovery request; search the message queue for target historical version data that matches the data information to be recovered; and perform data recovery on the database based on the target historical version data.

[0097] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0098] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0099] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0100] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0101] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0102] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0103] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0104] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0105] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0106] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A data recovery method, characterized in that: include: Get the historical version data of the database; Saving the historical version data to a message queue; Determining, according to the received data recovery request, the data information to be recovered corresponding to the data recovery request; Searching the message queue for target historical version data that matches the data information to be restored; The database is restored according to the target historical version data.

2. The method according to claim 1, characterized in that The obtaining of database historical version data specifically includes: Receiving a database operation instruction, wherein the database operation instruction includes: a data adding instruction, a data deleting instruction, and a data updating instruction; Obtain historical version data of the database before executing the database operation instruction.

3. The method according to claim 2, characterized in that The step of saving the historical version data to a message queue specifically includes: According to the data tables contained in the database, creating message topics corresponding to the data tables in the message queue; Determine storage information corresponding to the historical version data, wherein the storage information includes an instance name, a library name, and a data table name where the historical version data is stored in the database; Determine, according to the stored information, a first message topic that matches the historical version data in the message queue; The historical version data is saved in the first message topic.

4. The method according to claim 1, characterized in that: The data information to be restored includes storage information corresponding to the data to be restored, data restoration range and data restoration time; Then searching the message queue for target historical version data that matches the data information to be restored specifically includes: Searching the message queue for a second message topic that matches the storage information corresponding to the data to be restored; Determining candidate historical version data matching the data recovery moment in the second message topic; Determine a data recovery range according to the data information to be recovered, wherein the data recovery range includes: an entire data table or a part of a data table; According to the data recovery scope, target historical version data is determined from among the candidate historical version data.

5. The method according to claim 1, characterized in that: The restoring the database according to the target historical version data specifically includes: Generate a data update statement according to the target historical version data and data table structure; According to the data update statement, the data table corresponding to the data recovery request is updated to complete the data recovery of the data.

6. A data recovery device, characterized in that: include: A data acquisition unit, used to acquire historical version data of the database; A message queue storage unit, used to store the historical version data in a message queue; A to-be-restored data information determining unit, configured to determine, according to a received data recovery request, the to-be-restored data information corresponding to the data recovery request; A target data determination unit, configured to search the message queue for target historical version data that matches the data information to be restored; A data recovery unit is used to recover the database according to the target historical version data.

7. The device according to claim 6, characterized in that The message queue storage unit is specifically used for: According to the data tables contained in the database, creating message topics corresponding to the data tables in the message queue; Determine storage information corresponding to the historical version data, wherein the storage information includes an instance name, a library name, and a data table name where the historical version data is stored in the database; Determine the time when the database completes the operation corresponding to the operation executed in response to the database operation instruction; Determine, according to the stored information, a first message topic that matches the historical version data in the message queue; The historical version data and the operation completion time are associated and saved in the first message topic topic.

8. A data recovery device, comprising: processor; a memory arranged to store computer executable instructions which, when executed, cause the processor to: Get the historical version data of the database; Saving the historical version data to a message queue; Determining, according to the received data recovery request, the data information to be recovered corresponding to the data recovery request; Searching the message queue for target historical version data that matches the data information to be restored; The database is restored according to the target historical version data.

9. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, enable the electronic device to execute the data recovery method as described in any one of claims 1 to 5.

10. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the data recovery method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data flashback inquiry and recovery method of PostgreSQL database, device

    CN109299099A

  • Data backup and recovery method and device, equipment and medium

    CN114138556A

  • Data recovery method and device, equipment, storage medium and program product

    CN115202931A