Database hot backup method, device, electronic equipment and storage medium

By obtaining and packaging updated data blocks during the database backup process, and using redo logs and archive logs to update the target database, the problem of long database backup time during high transaction volume periods is solved, and backup efficiency and user experience are improved.

CN114595096BActive Publication Date: 2024-09-13湖南亚信安慧科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111154896.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2024-09-13
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

When the database is running, a large amount of redo logs and archive logs are generated during periods of high transaction volume, resulting in long database backup times and affecting database usage and user experience.

Method used

By obtaining the updated data blocks in the database to be backed up, packaging and copying them to the target database, using redo logs and archive logs to update the target database, ensuring that the target database is consistent with the database to be backed up, reducing the number of redo logs and archive logs, and improving backup efficiency.

Benefits of technology

It achieves rapid updating of data blocks in the target database, shortens backup time, improves backup efficiency, and reduces the impact on user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114595096B
    Figure CN114595096B
Patent Text Reader

Abstract

The embodiments of the present application provide a method, device, electronic device and storage medium for hot backup of a database, and relate to the technical field of database backup. The method comprises: obtaining updated data blocks in the database to be backed up during the first copy process, and packaging the data blocks to obtain at least one target data block; obtaining redo logs and archive logs in the database to be backed up during the second copy process; updating the data blocks in the target database according to the target data blocks, the redo logs and the archive logs, so that the target database is the same as the data blocks in the database to be backed up. The embodiments of the present application use redo logs and archive logs in the process of copying target data blocks, thereby greatly reducing the number of redo logs and archive logs, shortening the time of applying archive logs, and improving the efficiency of backup compared to using redo logs and archive logs throughout the process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of database backup, and in particular to a method, device, electronic device and storage medium for hot backup of a database. Background Art

[0002] With the advent of the information age, data security has received more and more attention. Data backup can be said to be an effective means of protecting data security. Currently, common database data backup methods include logical backup and physical backup.

[0003] Physical backups are divided into cold backups and hot backups. Cold backups are file copies when the database is closed or static, while hot backups are backups of the database while it is running. When the database is running, the changed data will first be written to the buffer, then refreshed to the disk to update the data, and the redo log and archive log will be used cyclically to record database changes. When the database is hot backed up, data is backed up based on the redo log and archive log.

[0004] When the transaction volume in the database is large, such as during the daytime business peak hours, there is a lot of data changed in the database, and the amount of redo logs and archive logs generated is large. If the database is to be backed up, it will take a long time to back up the data in the original database, causing the new database to be unready for a long time, affecting the use of the database and reducing the user experience. Summary of the invention

[0005] The embodiments of the present application provide a method, device, electronic device and storage medium for hot backup of a database, which can solve the above problems. The technical solution is as follows:

[0006] According to one aspect of an embodiment of the present application, a method for hot backup of a database is provided, the method comprising:

[0007] Acquire the updated data blocks in the database to be backed up during the first copy process, and pack the data blocks to obtain at least one target data block;

[0008] Obtain the redo logs and archive logs in the database to be backed up during the second copy process;

[0009] Update the data blocks in the target database according to the target data blocks, redo logs, and archive logs, so that the data blocks in the target database are the same as those in the database to be backed up;

[0010] The first copy process is to copy the predetermined data blocks in the database to be backed up to the target database;

[0011] The second copy process is to copy the target data block to the target database.

[0012] In a possible implementation, obtaining updated data blocks in the database to be backed up during the first copy process, and packaging the data blocks to obtain at least one target data block includes:

[0013] Record the unique identifier of the updated data block during the first copy process;

[0014] At the end of the first copy process, the recorded unique identifiers are arranged in the order of update time to obtain a first identifier list;

[0015] If it is determined that the first identification list is not empty, then the updated data blocks corresponding to the unique identifiers recorded in the first identification list are packaged according to the first identification list to obtain at least one target data block.

[0016] In another possible implementation, packing updated data blocks corresponding to the unique identifier recorded in the first identifier list according to the first identifier list to obtain at least one target data block includes:

[0017] Determine a preset number of unique identifiers from the first identifier list, and determine the data blocks to be packaged according to the determined preset number of unique identifiers;

[0018] Pack the data blocks to be packed and obtain the target data blocks.

[0019] In yet another possible implementation, packing the data blocks to be packed to obtain the target data blocks includes:

[0020] Determine the block header of the target data block according to a preset number of unique identifiers;

[0021] According to the arrangement order of the preset number of unique identifiers in the first identifier list, the data blocks to be packaged are arranged after the block header to obtain the target data block.

[0022] In yet another possible implementation, the block header of the target data block includes a unique identifier of the target data block, a sequence number of the target data block, a block header length of the target data block, a number of data blocks packaged with the target data block, and an identifier list of data blocks packaged with the target data block;

[0023] The block header of the target data block is determined according to a preset number of unique identifiers, including:

[0024] The preset number is used as the number of data blocks packaged as the target data blocks;

[0025] The unique identifiers of a preset number of data blocks are arranged in the time sequence of the preset number of data blocks being updated, to obtain a second identifier list as an identifier list of data blocks packaged with the target data blocks.

[0026] In yet another possible implementation, updating a data block in a target database according to the target data block, the redo log, and the archive log includes:

[0027] Determine the data block to be updated in the target database according to the block header of the target data block;

[0028] The data block to be updated is replaced by the data block packed in the target data block to obtain the replaced data block;

[0029] Update the replaced data blocks according to the redo log and archive log.

[0030] According to another aspect of an embodiment of the present application, a device for hot backup of a database is provided, the device comprising:

[0031] A first acquisition module is used to acquire the updated data blocks in the to-be-backed-up database during the first copy process, and to pack the data blocks to obtain at least one target data block;

[0032] A second acquisition module is used to acquire redo logs and archive logs in the database to be backed up during the second copy process;

[0033] A backup module, used for updating the data blocks in the target database according to the target data blocks, the redo logs and the archive logs, so that the data blocks in the target database are the same as those in the database to be backed up;

[0034] The first copy process is to copy the predetermined data blocks in the database to be backed up to the target database;

[0035] The second copy process is to copy the target data block to the target database.

[0036] According to another aspect of an embodiment of the present application, an electronic device is provided. The electronic device includes a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the above-mentioned database hot backup method.

[0037] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned database hot backup method are implemented.

[0038] In the embodiment of the present application, by acquiring updated data blocks in the database to be backed up, packaging the updated data blocks to obtain target data blocks, and copying the target data blocks to the target database, the data blocks in the target database can be updated very quickly; by using redo logs and archive logs in the process of copying the target data blocks, the number of redo logs and archive logs is greatly reduced, the time for applying the archive logs is shortened, and the efficiency of backup is improved compared to using redo logs and archive logs throughout the process. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0040] Figure 1 A schematic diagram of a system architecture for implementing hot backup of a database provided in an embodiment of the present application;

[0041] Figure 2 A schematic diagram of a database hot backup process provided in an embodiment of the present application;

[0042] Figure 3 A schematic diagram of a process of packaging data blocks provided in an embodiment of the present application;

[0043] Figure 4 A schematic diagram of a second copy process provided in an embodiment of the present application;

[0044] Figure 5 A schematic diagram of the structure of a data block provided in an embodiment of the present application;

[0045] Figure 6 A schematic diagram of a process for updating a data block provided in an embodiment of the present application;

[0046] Figure 7 A schematic diagram of the overall process of database hot backup provided in an embodiment of the present application;

[0047] Figure 8 A schematic diagram of the structure of a database hot backup device provided in an embodiment of the present application;

[0048] Fig. 9 A schematic diagram of the structure of an electronic device for hot backup of a database provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0050] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" indicates that it is implemented as "A", or is implemented as "A", or is implemented as "A and B".

[0051] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0052] First, several terms involved in this application are introduced and explained:

[0053] A database is a collection of large amounts of data that is stored in a computer for a long period of time, organized, shareable, and uniformly managed. It can also be described as a "warehouse that combines, stores, and manages data according to data structures."

[0054] A data block is the smallest unit for allocating and reading I / O in a database. It is logically composed of one or more operating system blocks and is a logical concept. The data block in the embodiment of the present application specifically refers to a fixed-size data block that constitutes a database file, and the size is generally 8KB or 16KB, etc.

[0055] Redo log is a log in physical format that records the information about modifications to physical data pages, that is, it records the physical changes to the database and is used in a circular mode.

[0056] Archive log is a backup of inactive redo log. By using archive log, all redo history records can be retained. When the database is in ARCHIVELOG archiving mode, the contents of the redo log are saved in the archive log. When the data file is backed up, the archive log and redo log can completely restore the database.

[0057] Database backup generally includes logical backup and physical backup. Logical backup refers to the use of backup SQL statements to reproduce database data; physical backup refers to the backup process of copying the database files that actually make up the database from one place to another.

[0058] Physical backup can be divided into cold backup and hot backup. Cold backup is the file copying when the database is closed or static, while hot backup is the backup of the database when the database is running.

[0059] The application scenario of the embodiment of the present application is in the process of hot backup of the database. In the prior art, when the database is running, the changed data blocks will be written into the buffer first, and then refreshed to the disk to update the data. At the same time, the redo log will be used cyclically to record these change operations, and the contents of the redo log will be written into the archive log. During the backup, data is backed up through the redo log and the archive log.

[0060] However, when there are many transactions in the database, such as during the daytime business peak period, there are many data changes in the database, and the amount of redo logs and archive logs generated is very large. If the database is to be backed up, it takes a long time to back up the data in the original database, resulting in the new database not being ready for a long time, affecting the use of the database and reducing the user experience.

[0061] The method, device, electronic device and storage medium for hot backup of a database provided in the present application are intended to solve the above technical problems in the prior art.

[0062] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.

[0063] Figure 1 A schematic diagram of the system architecture for implementing hot backup of a database provided in an embodiment of the present application, wherein the execution engine is the core service of the database for storing, processing and protecting data. After the execution engine processes the corresponding transaction, it will first store the data block in the data buffer and then refresh it to the database file.

[0064] When backing up the database, the execution engine can access the log and recovery management function module. The log and recovery management accesses the Redo log buffer and creates multiple Redo log files and Redo log archive files, namely redo logs and archive logs.

[0065] The embodiment of the present application adds a data block change tracking module to obtain the unique identifier of the updated data block and store it in the data block change index file. The method for hot backup of the database provided in the embodiment of the present application is a specific description of the contents of this section.

[0066] The present application provides a method for hot backup of a database. Figure 2 As shown, the method includes:

[0067] S101 , obtaining updated data blocks in the database to be backed up during the first copy process, and packaging the data blocks to obtain at least one target data block.

[0068] The first copy process refers to copying the predetermined data blocks in the database to be backed up to the target database. The predetermined data blocks refer to the data blocks determined during the copying. Since the database to be backed up is in operation and there are many data blocks in the database to be backed up, the copying takes a certain amount of time. During this period of time, the copied data blocks may be updated due to user operations and other reasons. These data blocks are updated data blocks. The updated data blocks in the database to be backed up during the first copy process are obtained, and these data blocks are packaged to obtain at least one target data block, which is convenient for the subsequent backup process.

[0069] S102: Obtain redo logs and archive logs in the database to be backed up during the second copy process.

[0070] The second copy process is to copy the packaged target data blocks to the target database. During this process, the redo logs and archive logs are applied to record the data blocks updated in the second copy process, that is, the redo logs and archive logs are obtained in the second copy process, instead of using the redo logs and archive logs throughout the database hot backup.

[0071] S103: Update the data blocks in the target database according to the target data blocks, the redo logs, and the archive logs, so that the data blocks in the target database are the same as those in the database to be backed up.

[0072] After the packaged target data blocks are copied to the target database, the data blocks packaged by the target data blocks in the target database can be updated according to the target data blocks. The specific process is described in the subsequent embodiments. Of course, the acquired redo logs and archive logs also need to be copied to the target database. The archive logs are applied in the target database to restore the data in the target database, so that the data blocks in the target database are the same as the data blocks in the database to be backed up, and the target database and the database to be backed up are in a consistent state, completing the hot backup of the database. The specific process is the prior art and is not specifically limited in the embodiments of the present application.

[0073] The embodiment of the present application obtains updated data blocks in the database to be backed up, packages the updated data blocks to obtain target data blocks, and copies the target data blocks to the target database, so that the data blocks in the target database can be updated very quickly; by using redo logs and archive logs in the target data block copying process, the number of redo logs and archive logs is greatly reduced, the time for applying archive logs is shortened, and the efficiency of backup is improved compared to using redo logs and archive logs throughout the process.

[0074] A possible implementation method is provided in the embodiment of the present application, such as Figure 3 As shown, obtaining the updated data blocks in the database to be backed up during the first copy process and packaging the data blocks to obtain the target data blocks includes:

[0075] S201. Record the unique identifier of the updated data block during the first copy process.

[0076] In the storage engine layer of the database, in order to ensure the reliability of the data and the speed of data writing, a data buffer is generally introduced, that is, the data is first cached in the data buffer and then refreshed to the disk. Therefore, the embodiment of the present application can obtain the unique identifier of the updated data block in the data buffer during the first copy process.

[0077] The unique identifier of a data block may include a sequence number, a file number, etc. in the database file where the data block is located, which can identify the position of the data block in the database. The data block can be quickly and accurately determined based on the unique identifier.

[0078] S202: When the first copy process is finished, the recorded unique identifiers are arranged in order of update time to obtain a first identifier list.

[0079] It should be understood that during the first copy process, the unique identifiers of the updated data blocks are continuously obtained and recorded. At the end of the first copy process, the recorded unique identifiers can be arranged in the order of update time to obtain a first identifier list. Specifically, for example, the data block change tracking interface getBlockIdIdsByNum can be set to obtain the identifier list.<fileId,blockId> , the embodiments of the present application are not specifically limited.

[0080] S203: If it is determined that the first identification list is not empty, then pack updated data blocks corresponding to the unique identifier recorded in the first identification list according to the first identification list to obtain at least one target data block.

[0081] If it is determined that the first identification list is not empty,<fileId,blockId> The length of the list is not 0, and it records the unique identifier of the updated data block.<fileId,blockId> List, will<fileId,blockId> The updated data blocks corresponding to the unique identifiers recorded in the list are packaged to obtain at least one target data block.

[0082] Figure 4 A schematic diagram of a second copy process provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, first call the data block change tracking interface getBlockIdIdsByNum to obtain<fileId,blockId> List, and then judge the obtained<fileId,blockId> Check if the length of the list is 0. If so, it means no data block has changed, then the process ends. If not, then build the block header of the target data block Chunk, and then call the database interface function to read it in a loop.<fileId,blockId> The data blocks recorded in the list are appended to the Chunk header array, and finally the Chunk is transferred to the target database.

[0083] The embodiment of the present application records the unique identifiers of the data blocks updated during the first copy process and constructs an identifier list in chronological order of the updates, thereby accurately determining and packaging the updated data blocks and avoiding the problem of missing certain data blocks and causing data confusion.

[0084] The embodiment of the present application also provides a possible implementation method, which packs updated data blocks corresponding to the unique identifier recorded in the first identifier list according to the first identifier list to obtain at least one target data block, including:

[0085] Determine a preset number of unique identifiers from the first identifier list, and determine the data blocks to be packaged according to the determined preset number of unique identifiers;

[0086] Pack the data blocks to be packed and obtain the target data blocks.

[0087] It should be understood that if the number of updated data blocks is small, that is, the number of unique identifiers of the updated data blocks recorded in the first identifier list is small, all the unique identifiers recorded in the first identifier list can be taken out, and the data blocks to be packaged can be determined based on the taken out unique identifiers; if the number of unique identifiers of the updated data blocks recorded is large, that is, the number of data blocks to be packaged is large, then a preset number of unique identifiers can be taken out each time, and the data blocks to be packaged can be determined based on the preset number of unique identifiers. The preset number can be determined based on actual conditions, and the embodiments of the present application do not make specific limitations.

[0088] Specifically, a preset database interface can be called to read the data block corresponding to the unique identifier according to the retrieved unique identifier, for example, from<fileId,blockId> Unique identifiers such as <1, 2>, <1, 3>, <2, 2>, and <3, 2> are taken out from the list, and the positions of the corresponding data blocks are determined according to the unique identifiers, and the corresponding data blocks are read. Then, these data blocks can be packaged to obtain the target data blocks. The specific process is described in the subsequent embodiments.

[0089] The embodiment of the present application determines the data blocks to be packaged by determining a preset number of unique identifiers from the first identifier list. The number of target data blocks can be determined based on the number of data blocks updated in actual conditions, and can be adjusted in real time, thereby improving the efficiency of data block packaging.

[0090] The embodiment of the present application also provides a possible implementation method, which packs the data blocks to be packed to obtain the target data blocks, including:

[0091] Determine the block header of the target data block according to a preset number of unique identifiers;

[0092] According to the arrangement order of the preset number of unique identifiers in the first identifier list, the preset number of data blocks are arranged after the block header to obtain the target data block.

[0093] Figure 5 A schematic diagram of a data block structure provided in an embodiment of the present application, such as Figure 4 As shown, the target data block includes a block header and continuous data blocks to be packaged, that is, the block header of the target data block Chunk is the Chunk header, and the data blocks connected after the Chunk header include BlockId1 Data, BlockId2 Data, BlockId3 Data, ..., BlockIdn Data.

[0094] The block header of the target data block can also be said to be a unique identifier of the target data block, which can be determined based on the unique identifiers of the data blocks packaged with the target data block. How to determine it specifically will be described in subsequent embodiments.

[0095] After determining the block header of the target data block, the data blocks to be packaged may be arranged at the beginning according to the corresponding arrangement order of the unique identifiers of the data blocks to be packaged in the first identifier list to form the target data block.

[0096] The embodiment of the present application determines the block header of the target data block through the unique identifier of the data block to be packaged, and arranges the block header after the block header in the order of arrangement of the unique identifiers of the data blocks to be packaged in the first identifier list to form the target data block. The data blocks can be packaged very quickly and arranged in order, which is convenient for subsequent updating of the data blocks in the target database.

[0097] The embodiment of the present application also provides a possible implementation method, wherein the block header of the target data block includes a unique identifier of the target data block, a sequence number of the target data block, the number of data blocks packaged with the target data block, and an identifier list of data blocks packaged with the target data block;

[0098] The block header of the target data block is determined according to a preset number of unique identifiers, including:

[0099] The preset number is used as the number of data blocks packaged as the target data blocks;

[0100] The unique identifiers of a preset number of data blocks are arranged in the time sequence of the preset number of data blocks being updated, to obtain a second identifier list as an identifier list of data blocks packaged with the target data blocks.

[0101] For example, the following is the content of the block header of the target data block Chunk:

[0102] (1) Chunk header keyword is a preset fixed value, such as 0xFEFEFEFE, which is used to neatly arrange multiple target data blocks and occupies 4 bytes.

[0103] (2) Chunk header length: The specific value is the number of packed data blocks*8+16, which occupies 4 bytes.

[0104] (3) Chunk header sequence number is a constant that increases from 1. Its purpose is to arrange multiple target data blocks in sequence. It occupies 4 bytes.

[0105] (4) The number of data blocks packed in Chunk, which occupies 4 bytes.

[0106] (5) A list of identifiers of data blocks packed in Chunk, where each<fileId,blockIdId> Sort by update order.

[0107] In the embodiment of the present application, the block header of the target data block is determined by the number of unique identifiers of the data blocks to be packaged, the arrangement order, etc., so that the target data block can be uniquely identified and the subsequent update of the data blocks in the target database is facilitated.

[0108] The present application also provides a possible implementation method, such as Figure 6 As shown, according to the target data blocks, redo logs, and archive logs, the data blocks in the target database are updated, including:

[0109] S301, determining a data block to be updated in a target database according to a block header of a target data block;

[0110] S302, replacing the data block to be updated with the data block packaged in the target data block to obtain a replaced data block;

[0111] S303: Update the replaced data block according to the redo log and the archive log.

[0112] Specifically, the position of the data block to be updated in the target database can be determined based on the identification list of the data blocks packaged with the target data block contained in the block header of the target data block, and then the data block packaged in the target data block replaces the corresponding data block to be updated to obtain the replaced data block.

[0113] It should be noted that the replaced data blocks also need to be updated according to the redo log and the archive log. Because in the process of copying the target data blocks from the database to be backed up to the target database, as the data blocks to be backed up run, the packaged data blocks may also change. Therefore, the replaced data blocks can be updated according to the redo log and the archive log to make the target database consistent with all the data blocks in the data blocks to be backed up.

[0114] A possible implementation method is also provided in the embodiment of the present application: Figure 7 A schematic diagram of the overall process of database hot backup provided by the embodiment of the present application is as follows: Figure 7 As shown, the database to be backed up and the target database interact with each other to implement the process of database hot backup.

[0115] Specifically, the target database requests backup from the database to be backed up;

[0116] The data block to be backed up starts data change tracking, and then copies the predetermined data block to the target database, which is the first copy process. After the first copy process is completed, the data block change tracking is stopped, and then Redo log archiving is started. The target data block is copied to the target database, which is the second copy process.

[0117] The target database can replace the corresponding data block according to the target data block, that is, update the data block in the target database;

[0118] After the second copy process in the backup database is completed, stop archiving the redo logs, and then copy the redo logs and archive logs to the target database;

[0119] The target database can apply redo logs and archive logs to restore it to the same state as the database to be backed up.

[0120] The present application embodiment provides a device for hot backup of a database, such as Figure 8 As shown, the device may include: a first acquisition module 110, a second acquisition module 120 and a backup module 130, wherein:

[0121] A first acquisition module 110 is used to acquire data blocks updated in the database to be backed up during the first copy process, and to pack the data blocks to obtain at least one target data block;

[0122] The second acquisition module 120 is used to acquire the redo log and archive log in the database to be backed up during the second copy process;

[0123] The backup module 130 is used to update the data blocks in the target database according to the target data blocks, the redo logs and the archive logs, so that the data blocks in the target database are the same as those in the database to be backed up;

[0124] The first copy process is to copy the predetermined data blocks in the database to be backed up to the target database;

[0125] The second copy process is to copy the target data block to the target database.

[0126] The device for hot backup of a database provided in the embodiment of the present application specifically executes the above method embodiment process. For details, please refer to the content of the above method embodiment for hot backup of a database, which will not be repeated here. The device for hot backup of a database provided in the embodiment of the present application can update the data blocks in the target database very quickly by obtaining the updated data blocks in the database to be backed up, packaging the updated data blocks to obtain the target data blocks, and copying the target data blocks to the target database; by using redo logs and archive logs in the process of copying the target data blocks, the number of redo logs and archive logs is greatly reduced, the time for applying the archive logs is shortened, and the efficiency of the backup is improved compared to using redo logs and archive logs throughout the process.

[0127] In a possible implementation, the first acquisition module 110 includes:

[0128] A recording module, used for recording a unique identifier of an updated data block during the first copy process;

[0129] An arrangement module is used to arrange the recorded unique identifiers in the order of update time at the end of the first copy process to obtain a first identifier list;

[0130] The packing module is used to pack the updated data blocks corresponding to the unique identifier recorded in the first identification list according to the first identification list to obtain at least one target data block if it is determined that the first identification list is not empty.

[0131] In another possible implementation, the packaging module includes:

[0132] A determination subunit, configured to determine a preset number of unique identifiers from the first identifier list, and determine data blocks to be packaged according to the determined preset number of unique identifiers;

[0133] Pack the data blocks to be packed and obtain the target data blocks.

[0134] In yet another possible implementation, the determining subunit includes:

[0135] A packing subunit, used for determining a block header of a target data block according to a preset number of unique identifiers;

[0136] According to the arrangement order of the preset number of unique identifiers in the first identifier list, the data blocks to be packaged are arranged after the block header to obtain the target data block.

[0137] In another possible implementation, the block header of the target data block includes a unique identifier of the target data block, a sequence number of the target data block, a block header length of the target data block, the number of data blocks packaged with the target data block, and an identifier list of data blocks packaged with the target data block, and the packaging subunit includes:

[0138] The block header subunit is used to package a preset number of data blocks as the number of target data blocks;

[0139] The unique identifiers of a preset number of data blocks are arranged in the time sequence of the preset number of data blocks being updated, to obtain a second identifier list as an identifier list of data blocks packaged with the target data blocks.

[0140] In yet another possible implementation, the backup module 130 includes:

[0141] A replacement module, used for determining a data block to be updated in a target database according to a block header of a target data block;

[0142] The data block to be updated is replaced by the data block packed in the target data block to obtain the replaced data block;

[0143] Update the replaced data blocks according to the redo log and archive log.

[0144] In an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory. The processor executes the above-mentioned computer program to implement the steps of the method for hot backup of a database. Compared with the prior art, the following can be achieved: by obtaining updated data blocks in the database to be backed up, packaging the updated data blocks to obtain target data blocks, and copying the target data blocks to the target database, the data blocks in the target database can be updated very quickly; by using redo logs and archive logs in the process of copying the target data blocks, the number of redo logs and archive logs is greatly reduced, the time for applying the archive logs is shortened, and the efficiency of backup is improved compared with using redo logs and archive logs throughout the process.

[0145] In an alternative embodiment, an electronic device is provided, such as Fig. 9 As shown, Fig. 9 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0146] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0147] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0148] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.

[0149] The memory 4003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.

[0150] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0151] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0152] The above is only an optional implementation method for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.

Claims

1. A method for hot backup of a database. It is characterized in that The method comprises: Acquire the updated data blocks in the database to be backed up during the first copy process, and pack the data blocks to obtain at least one target data block; Obtaining redo logs and archive logs in the database to be backed up during the second copy process; According to the target data blocks, the redo logs and the archive logs, the data blocks in the target database are updated so that the data blocks in the target database are the same as those in the database to be backed up; The first copy process is to copy the predetermined data blocks in the database to be backed up to the target database; The second copying process is to copy the target data block to the target database; The acquiring of the updated data blocks in the to-be-backed-up database during the first copy process and packaging of the data blocks to obtain at least one target data block includes: Recording the unique identifier of the updated data block during the first copying process; At the end of the first copying process, the recorded unique identifiers are arranged in the order of update time to obtain a first identifier list; If it is determined that the first identification list is not empty, the updated data blocks corresponding to the unique identifiers recorded in the first identification list are packaged according to the first identification list to obtain the at least one target data block.

2. The method for hot backup of a database according to claim 1, It is characterized in that The step of packing the updated data blocks corresponding to the unique identifier recorded in the first identifier list according to the first identifier list to obtain the at least one target data block includes: Determine a preset number of unique identifiers from the first identifier list, and determine the data blocks to be packaged according to the determined preset number of unique identifiers; The data blocks to be packaged are packaged to obtain the target data blocks.

3. The method for hot backup of a database according to claim 2, It is characterized in that The step of packing the data blocks to be packed to obtain the target data blocks includes: Determine the block header of the target data block according to the preset number of unique identifiers; According to the arrangement order of the preset number of unique identifiers in the first identifier list, the data blocks to be packaged are arranged after the block header to obtain the target data block.

4. The method for hot backup of a database according to claim 3, It is characterized in that The block header of the target data block includes a unique identifier of the target data block, a sequence number of the target data block, a block header length of the target data block, the number of data blocks packaged by the target data block, and an identifier list of data blocks packaged by the target data block; Determining the block header of the target data block according to the preset number of unique identifiers includes: Taking the preset number as the number of data blocks packaged with the target data block; The unique identifiers of the preset number of data blocks are arranged in the time sequence of the update of the preset number of data blocks to obtain a second identifier list as the identifier list of the data blocks packaged by the target data blocks.

5. The method for hot backup of a database according to claim 1 or 4, It is characterized in that The updating of the data blocks in the target database according to the target data blocks, the redo logs and the archive logs includes: Determining a data block to be updated in the target database according to a block header of the target data block; Replacing the data block to be updated with the data block packaged in the target data block to obtain a replaced data block; The replaced data block is updated according to the redo log and the archive log.

6. A device for hot backup of a database, It is characterized in that The device comprises: A first acquisition module, used for acquiring data blocks updated in the database to be backed up during the first copy process, and packing the data blocks to obtain at least one target data block; A second acquisition module is used to acquire the redo log and the archive log in the database to be backed up during the second copy process; A backup module, configured to update data blocks in a target database according to the target data blocks, the redo logs and the archive logs, so that the data blocks in the target database are the same as those in the database to be backed up; The first copy process is to copy the predetermined data blocks in the database to be backed up to the target database; The second copying process is to copy the target data block to the target database; The first acquisition module is specifically used to: Recording the unique identifier of the updated data block during the first copying process; At the end of the first copying process, the recorded unique identifiers are arranged in the order of update time to obtain a first identifier list; If it is determined that the first identification list is not empty, the updated data blocks corresponding to the unique identifiers recorded in the first identification list are packaged according to the first identification list to obtain the at least one target data block.

7. An electronic device comprising a memory, a processor and a computer program stored in the memory, It is characterized in that The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method for hot backup of a database according to any one of claims 1 to 5 are implemented.