Online backup device and method

By locking database objects and generating a backup object list during backup, combined with transaction snapshot technology, the problem of data duplication in incremental backup is solved, ensuring data consistency and business continuity during the backup process, and improving backup efficiency. .

CN118331795BActive Publication Date: 2024-10-11TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410773271.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-10-11
Estimated Expiration
2044-06-17

AI Technical Summary

Technical Problem

Incremental backup may cause data duplication during the backup process, which may lead to inconsistencies between the data to be backed up and the backup results, affecting business continuity.

Method used

By locking the backup objects of the target database during backup, generating a backup object list, and using transaction snapshots to determine the backup scope, ensuring the consistency of metadata and data, thereby avoiding repeated backup of data.

Benefits of technology

Without stopping the business, ensure the consistency of backup data, avoid data duplication, ensure that the backup process is not affected by database writing and deletion, and improve backup efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118331795B_ABST
    Figure CN118331795B_ABST
Patent Text Reader

Abstract

The present application provides an online backup device and method, the device includes: a task distribution module and multiple task execution modules; the task distribution module is used to obtain data information of the current node of the target database and data information of the historical backup of the target database; wherein the data information of the current node of the target database includes the first metadata and the first data, and the data information of the historical backup of the target database includes the second data; the task distribution module is also used to determine the backup object list and the backup range based on the first metadata, the first data and the second data; and the backup object of the target database is locked, the backup object list and the backup range are used as the data to be backed up, and the task of backing up the data to be backed up is distributed to multiple task execution modules; the task execution module is used to execute the tasks it has received. The present application can avoid the problem of duplicate backup data in the backup process of incremental backup.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to an online backup device and method. Background Art

[0002] Many applications will back up the database regularly to ensure data security, accuracy, and compliance. Full backup is to back up all the information in the database at the current moment to ensure data security. However, due to the large amount of data, full backup has the problem of long backup time, which will affect the business during the backup period. In order to ensure that the business is not affected during the backup period, incremental backup based on full backup can solve the problem of long full backup time.

[0003] However, even incremental backup requires stopping business during the backup period. If business is not stopped, the incremental backup will cause duplicate backup data during the backup process, which will lead to inconsistencies between the data to be backed up and the backup results. Summary of the invention

[0004] In order to overcome the technical problem of duplicate backup data during the backup process in incremental backup existing in the related art, the embodiments of the present application provide an online backup device and method.

[0005] This application is implemented through the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides an online backup device, including: a task distribution module and multiple task execution modules.

[0007] The task distribution module is used to obtain data information of the current node of the target database and data information of the historical backup of the target database; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of a transaction snapshot, and the data information of the historical backup of the target database includes second data.

[0008] The task distribution module is also used to generate a backup object list based on the first metadata; and determine the backup range based on the first data and the second data; and lock the backup object of the target database, use the backup object list and the backup range as the data to be backed up, and distribute the task of backing up the data to be backed up to multiple task execution modules.

[0009] The task execution module is used to execute the tasks it receives.

[0010] In conjunction with the first aspect, in some possible implementations, the backup object list includes all the first metadata; and the task distribution module is specifically configured to:

[0011] The changed data between the first data and the second data are compared to determine the backup scope.

[0012] In conjunction with the first aspect, in some possible implementations, the online backup device further includes: a task recovery module;

[0013] The task recovery module is used to replace the metadata at the recovery data location with the metadata in the backup data when receiving a data recovery instruction, and record the corresponding relationship between the data after recovery and the data before recovery.

[0014] In combination with the first aspect, in some possible implementations, the online backup device further includes: a task queue module.

[0015] The task queue module is used to obtain the current memory of each task execution module and calculate the maximum number of threads for backing up data for each task execution module based on the current memory of each task execution module.

[0016] The task execution module is also used to execute the received tasks according to the maximum number of threads of the task execution module.

[0017] In conjunction with the first aspect, in some possible implementations, the task queue module is further used to:

[0018] Get the memory usage of each data to be backed up.

[0019] For the current memory of each task execution module, the product of the current memory of the task execution module and the preset ratio is calculated to obtain the maximum current memory of the task execution module used for backup.

[0020] The quotient of the maximum current memory used for backup of the task execution module and the memory usage of each data to be backed up is calculated to obtain the maximum number of threads for simultaneously backing up data of the task execution module.

[0021] In combination with the first aspect, in some possible implementations, the online backup device further includes: a task checking module.

[0022] The task check module is used to perform backup check and recovery check to obtain the results of the backup check and the recovery check; when the result of the backup check is passed and the result of the recovery check is passed, the control task distribution module evenly distributes the task of backing up the data to be backed up to multiple task execution modules.

[0023] In conjunction with the first aspect, in some possible implementations, the task checking module is specifically configured to:

[0024] Check whether the database cluster status is read-only, check whether the storage space of the backup location is sufficient, check whether the historical backup is complete, check whether the historical backup is valid, check whether there are DDL-related locks, check whether there is a full backup in the historical backup, check whether there is a backup object list, and check whether the backup-related information is updated.

[0025] The backup check result is passed when the database cluster is in read-only state, the storage space of the backup location is sufficient, the historical backup is complete, the historical backup is valid, there is no DDL-related lock, there is a full backup in the historical backup, there is a backup object list, and there is updated backup-related information.

[0026] Check whether the versions of the cluster being restored are consistent with those of the cluster being backed up, whether the status of the cluster being restored is RECOVERY, whether the storage space at the recovery location is sufficient, whether the backups to the specified recovery point are valid, whether there are any ongoing read and write operations, and verify the backup data.

[0027] The recovery check is passed when the versions of the restored cluster and the backup cluster are consistent, the status of the restored cluster is RECOVERY, the storage space of the recovery location is sufficient, the backups of the specified recovery point are valid, there are no ongoing read and write operations, and the checksum of the backup data is the same as the checksum in the backup-related information.

[0028] When the result of the backup check is passed and the result of the recovery check is passed, the control task distribution module evenly distributes the task of backing up the data to be backed up to the multiple task execution modules.

[0029] In conjunction with the first aspect, in some possible implementations, the task distribution module is further used to:

[0030] Get the number of task execution modules and the amount of data to be backed up;

[0031] Calculate the quotient of the amount of data to be backed up and the number of task execution modules;

[0032] If the quotient is an integer, then the task amount of each task execution module to back up the data to be backed up is the same, and the task amount is the quotient;

[0033] If the quotient is not an integer, the quotient is rounded down to an integer as the first component;

[0034] Calculate the product of the floor-rounded value of the quotient and the number of task execution modules to obtain a first calculation result;

[0035] Calculate the difference between the amount of data to be backed up and the first calculation result to obtain the amount of data to be backed up that has not been allocated;

[0036] According to a preset allocation order, the unallocated data to be backed up are allocated to the corresponding task execution modules, and the task execution modules allocated to the unallocated data to be backed up are recorded as first-category task execution modules, and the value of the second component of the first-category task execution modules is set to 1, and the task execution modules not allocated to the unallocated data to be backed up are recorded as second-category task execution modules, and the value of the second component of the second-category task execution modules is set to 0;

[0037] For each task execution module, the sum of the first component and the second component of the task execution module is used as the task amount of the task execution module for backing up the data to be backed up.

[0038] In conjunction with the first aspect, in some possible implementations, the task execution module is further configured to:

[0039] When the backup of the task execution module is completed or an error occurs in the backup of the task execution module, the completion information or error information is sent to the task distribution module.

[0040] The online backup device also includes: a task visualization module.

[0041] The task visualization module is used to visualize the process of backing up data in the task execution module based on the MVCC technology.

[0042] In a second aspect, an embodiment of the present application provides an online backup method, including:

[0043] The data information of the current node of the target database and the data information of the historical backup of the target database are obtained; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of a transaction snapshot, and the data information of the historical backup of the target database includes second data.

[0044] A backup object list is generated based on the first metadata.

[0045] A backup range is determined based on the first data and the second data.

[0046] The backup object of the target database is locked, the backup object list and the backup range are used as data to be backed up, and the data to be backed up is divided into multiple parts for separate backing up.

[0047] It can be understood that the beneficial effects of the second aspect mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0048] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0049] This application ensures metadata consistency by locking the backup object of the target database and generating a backup object list during backup, determines the first data at the start of backup by means of transaction snapshot, and then determines the backup range based on the second data and the first data in the historical backup data, ensuring that the backup data will not be affected by database writing and deletion. By ensuring data consistency and metadata consistency respectively, it is ensured that data will not be backed up repeatedly during the backup process without stopping the business.

[0050] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0052] Figure 1 It is a structural diagram of an online backup device provided by an embodiment of the present application;

[0053] Figure 2 is a structural diagram of an online backup device provided by another embodiment of the present application;

[0054] Figure 3 It is a flowchart of an online backup method provided by an embodiment of the present application;

[0055] Figure 4 This is an online backup flow chart provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0057] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0058] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0059] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0060] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0061] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0062] Incremental backup also requires stopping business during the backup period. If business is not stopped, the incremental backup will cause duplicate backup data during the backup process, which will lead to inconsistencies between the data to be backed up and the backup results.

[0063] Based on the above problems, the following thoughts are raised: Data backup is a time-consuming process. The backup process does not require business to be stopped, but data consistency must be guaranteed. All the data that can be seen at the current moment when the backup starts is all the data at the end of the backup. Several situations need to be considered:

[0064] 1. Metadata consistency: Database objects seen at the start of the backup are not allowed to be deleted or modified during the backup process. Newly added database objects during the backup process are also not included in the backup scope. This is achieved by locking and generating a backup object list at the start of the backup.

[0065] 2. Data consistency: All data visible at the start of the backup needs to be backed up, and will not be affected by the data written to the database during the backup process. Data written during the backup process cannot be backed up. The data seen at the start of the backup is determined based on the transaction snapshot, thereby determining the backup scope. At the same time, it is guaranteed that the data that needs to be backed up during the backup process cannot be garbage collected.

[0066] 3. Consistency of metadata and data: Meta information such as table ID and library ID needs to ensure that metadata and data are consistent.

[0067] Taking the above considerations into consideration, an embodiment of the present application provides an online backup method, which ensures the consistency of metadata by locking the backup object of the target database and generating a backup object list during backup, determines the first data when starting the backup through a transaction snapshot, and then determines the backup range based on the second data and the first data in the historical backup data, thereby ensuring that the backup data will not be affected by database writing and deletion, and ensuring that the backup data will not be repeated during the backup process without stopping the business.

[0068] Figure 1 is a schematic diagram of the structure of an online backup device provided by an embodiment of the present application, referring to Figure 1 , the device is described in detail as follows:

[0069] An online backup device includes: a task distribution module 101 and a plurality of task execution modules 102.

[0070] The task distribution module 101 is used to obtain data information of the current node of the target database and data information of the historical backup of the target database; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of a transaction snapshot, and the data information of the historical backup of the target database includes second data.

[0071] The task distribution module 101 is also used to generate a backup object list based on the first metadata; and determine the backup range based on the first data and the second data; and lock the backup object of the target database, use the backup object list and the backup range as the data to be backed up, and distribute the task of backing up the data to be backed up to multiple task execution modules 102.

[0072] The task execution module 102 is used to execute the received task.

[0073] Specifically, the first data records the metadata of the data. Due to the MVCC mechanism, the same data may have multiple versions. The first data records the information of all data at different times, so that different versions of the data can be obtained at different times.

[0074] The online backup device ensures metadata consistency by locking the backup object of the target database and generating a backup object list during backup, determines the first data at the start of backup by means of transaction snapshot, and then determines the backup range according to the second data and the first data in the historical backup data, thereby ensuring that the backup data will not be affected by database writing and deletion. By ensuring data consistency and metadata consistency respectively, it is ensured that data will not be backed up repeatedly during the backup process without stopping the business.

[0075] In addition, if databases A, B, and C are backed up, then metadata such as table ID and library ID in database A' after the backup should be the same as those of database A before the backup; metadata such as table ID and library ID in database B' after the backup should be the same as those of database B before the backup; metadata such as table ID and library ID in database C' after the backup should be the same as those of database C before the backup.

[0076] Specifically, the data in a table is divided into two parts: metadata and data. Metadata is stored in a distributed key-value database shared by multiple instances, and the data itself is stored in S3. Compared with data, metadata is small in size, so all metadata needs to be backed up for each incremental backup. The data volume is large, and it is necessary to ensure that only the data modified between the current backup point and the previous backup point is backed up during each incremental backup. Since metadata is written in kv format, all kvs are read out during the backup. For data, it is stored on S3. When backing up, it does not need to be read locally, but the data is directly copied from one S3 bucket to another S3 bucket, which reduces network transmission and saves memory usage of local cluster nodes.

[0077] When the task execution component is responsible for processing the actual task, it also splits the task of a table into two parts, processing the metadata part first and then the data part. Incremental backup needs to record the data that has been backed up at the previous backup point, based on the data backed up at the previous backup point, and then compare it with all the current data to determine the data that needs to be backed up for the actual current incremental backup. Therefore, the key to incremental backup is the data backup table, which will be updated after each backup task to provide a reference for the next backup task.

[0078] Exemplarily, the backup object list includes all the first metadata.

[0079] The task distribution module 101 is specifically used for:

[0080] The changed data between the first data and the second data are compared to determine the backup scope.

[0081] For example, Figure 2 As shown, the online backup device further includes: a task recovery module 103;

[0082] The task recovery module 103 is used to replace the metadata at the recovery data location with the metadata in the backup data when receiving the data recovery instruction, and record the corresponding relationship between the data after recovery and the data before recovery.

[0083] Specifically, if you only update the data backup table at each backup, the following problems may occur: When restoring data, there may be metadata conflicts. The table with ID=1 may be backed up during the backup, and then the table is deleted. Then a new table is created with the ID of 1. When restoring, two tables with ID=1 will appear, causing duplication. Therefore, when restoring data, the metadata in the backup data (the backed-up table with ID=1) is used to replace the metadata at the restored data location (the newly created table with ID=1), and the corresponding relationship between the restored data and the data before restoration is recorded when restoring the data (the restored table with ID=1 corresponds to the table with ID=1 before restoration). In this way, two tables with ID=1 will not be formed after restoration, avoiding duplication during restoration.

[0084] For example, Figure 2 As shown, the online backup device further includes: a task queue module 104 .

[0085] The task queue module 104 is used to obtain the current memory of each task execution module 102 and calculate the maximum number of threads for each task execution module 102 to back up data according to the current memory of each task execution module 102 .

[0086] The task execution module 102 is further configured to execute the received task according to the maximum number of threads of the task execution module 102 .

[0087] Exemplarily, the task queue module 104 is further used for:

[0088] Get the memory usage of each data to be backed up.

[0089] For the current memory of each task execution module 102 , the product of the current memory of the task execution module 102 and the preset ratio is calculated to obtain the maximum current memory of the task execution module 102 used for backup.

[0090] The quotient of the maximum current memory used for backup by the task execution module 102 and the memory usage of each data to be backed up is calculated to obtain the maximum number of threads of the task execution module 102 that simultaneously back up data.

[0091] Specifically, there is an upper limit on the memory of each task execution module. When the amount of data distributed to the task execution module for backup is huge, the memory will be insufficient. When the memory is insufficient, backup cannot be performed and an error will be reported. In order to ensure the stable operation of the backup system, the maximum number of threads is set so that each task execution module can stably back up data and ensure the stable operation of the backup system.

[0092] For example, Figure 2 As shown, the online backup device further includes: a task checking module 105 .

[0093] The task check module 105 is used to perform backup check and recovery check to obtain the results of the backup check and the recovery check; when the result of the backup check is passed and the result of the recovery check is passed, the control task distribution module 101 evenly distributes the task of backing up the data to be backed up to multiple task execution modules 102.

[0094] Specifically, in order to ensure that there is no duplication during the data backup process, it is necessary to perform a backup check and a recovery check before distributing the data to the multiple task execution modules 102 for backup.

[0095] Exemplarily, the task checking module 105 is specifically used for:

[0096] Check whether the database cluster status is read-only, check whether the storage space of the backup location is sufficient, check whether the historical backup is complete, check whether the historical backup is valid, check whether there are DDL-related locks, check whether there is a full backup in the historical backup, check whether there is a backup object list, and check whether the backup-related information is updated.

[0097] The backup check result is passed when the database cluster is in read-only state, the storage space of the backup location is sufficient, the historical backup is complete, the historical backup is valid, there is no DDL-related lock, there is a full backup in the historical backup, there is a backup object list, and there is updated backup-related information.

[0098] Check whether the versions of the cluster being restored are consistent with those of the cluster being backed up, whether the status of the cluster being restored is RECOVERY, whether the storage space at the recovery location is sufficient, whether the backups to the specified recovery point are valid, whether there are any ongoing read and write operations, and verify the backup data.

[0099] The recovery check is passed when the versions of the restored cluster and the backup cluster are consistent, the status of the restored cluster is RECOVERY, the storage space of the recovery location is sufficient, the backups of the specified recovery point are valid, there are no ongoing read and write operations, and the checksum of the backup data is the same as the checksum in the backup-related information.

[0100] When the result of the backup check is passed and the result of the recovery check is passed, the control task distribution module 101 evenly distributes the task of backing up the data to be backed up to the plurality of task execution modules 102 .

[0101] Specifically, the backup check includes:

[0102] 1. Check whether the database cluster is in a read-only state: Check whether the cluster is in a read-only state. Restrict DDL through metadata. DML operations can be unrestricted based on multiple versions.

[0103] 2. Check whether the storage space of the backup location is sufficient: calculate the size of the backup data and the remaining space of the user's S3 service. If the remaining space is smaller than the backup size, exit directly.

[0104] 3. Check the integrity of the historical backup: If the historical backup is a full backup: Check whether the backup path exists. If it already exists, check whether it is complete and exit with an error. If the historical backup is an incremental backup: Check until the most recent valid backup. If there is an invalid backup, prompt the user to delete it and exit.

[0105] 4. Check whether the historical backup is valid: whether the backup point information is marked as complete.

[0106] 5. Check whether there are DDL-related locks: Check whether there are DDL-related locks. If so, exit.

[0107] 6. Check whether there is a full backup in the historical backup. Make sure there is at least a full backup currently.

[0108] 7. Check whether there is a backup object list: confirm the backup object. It cannot be deleted during the backup process. The newly added object is not in the backup object list.

[0109] 8. Check whether the backup-related information is updated: The backup-related information may include the backup time, backup cycle, backup level, backup ID, and completion mark.

[0110] Specifically, the recovery check includes:

[0111] 1. Check whether the versions of the cluster being restored and the cluster being backed up are consistent.

[0112] 2. Check whether the status of the data recovery cluster is RECOVERY: Before recovery, the recovery cluster status is set to RECOVERY and all write operations are prohibited.

[0113] 3. Check whether the storage space at the recovery location is sufficient: Compare the relationship between the metadata backup data and the remaining local space, and the relationship between the data backup data and the remaining S3 space.

[0114] 4. Check whether the backups to the specified recovery point are all valid: Get the backup cycle and backup point: If the user does not specify the backup cycle and backup point, get the latest cycle and the latest backup point. If the user specifies the backup cycle, get the latest backup point of the cycle. Otherwise, install the user-specified recovery. Check whether the backups from the backup cycle to the specified recovery point are all valid.

[0115] 5. Check whether there are any ongoing read or write operations: Check the lock status of all backup-related database tables. If there are locks, it means that other tasks are currently reading or writing.

[0116] 6. Verify backup data: Calculate the verification values ​​of all backup data files from the backup cycle to the specified recovery point, and compare them with the verification values ​​saved in the backup point information (information related to the backup).

[0117] Exemplarily, the task distribution module 101 is further used for:

[0118] Obtain the number of task execution modules 102 and the amount of data to be backed up;

[0119] Calculate the quotient of the amount of data to be backed up and the amount of task execution modules 102;

[0120] If the quotient is an integer, then the task amount of each task execution module 102 for backing up the data to be backed up is the same, and the task amount is the quotient;

[0121] If the quotient is not an integer, the quotient is rounded down to an integer as the first component;

[0122] Calculate the product of the floor-rounded value of the quotient and the number of task execution modules to obtain a first calculation result;

[0123] Calculate the difference between the amount of data to be backed up and the first calculation result to obtain the amount of data to be backed up that has not been allocated;

[0124] According to the preset allocation order, the unallocated data to be backed up are allocated to the corresponding task execution modules 102, and the task execution modules 102 allocated to the unallocated data to be backed up are recorded as first-category task execution modules, and the value of the second component of the first-category task execution modules is set to 1, and the task execution modules 102 not allocated to the unallocated data to be backed up are recorded as second-category task execution modules, and the value of the second component of the second-category task execution modules is set to 0;

[0125] For each task execution module 102 , the sum of the first component and the second component of the task execution module 102 is used as the task amount of the task execution module 102 for backing up the data to be backed up.

[0126] Specifically, in order to ensure that each task execution module 102 can evenly undertake the backup task, the task of backing up the data to be backed up is evenly distributed to each task execution module 102. In addition, evenly distributing the tasks to each task execution module 102 can also ensure that all task execution modules complete the tasks (complete the backup) at the same time as much as possible, thereby improving the backup efficiency, reducing the backup time, improving the operating efficiency of the online backup device, and reducing the waste of resources.

[0127] Exemplarily, the task execution module 102 is further configured to:

[0128] When the task execution module 102 completes the backup or an error occurs in the backup of the task execution module 102 , the completion information or the error information is sent to the task distribution module 101 .

[0129] Specifically, in order to improve backup efficiency and ensure that the backup is complete, it is necessary to ensure that each task execution module 102 completes the task. It is set to pass information to the task distribution module 101 when the backup is completed or a backup error occurs. This can more accurately determine which part has a backup error, and promptly check and resolve the problem and perform the backup again.

[0130] like Figure 2 As shown, the online backup device further includes: a task visualization module 106 .

[0131] The task visualization module 106 is used to visualize the process of backing up data by the task execution module 102 based on the MVCC technology.

[0132] Specifically, the problem of data invisibility in online backup can be solved by performing visibility detection on data during backup through the MVCC mechanism in the database.

[0133] Figure 3 is a schematic diagram of the process of an online backup method provided by an embodiment of the present application, referring to Figure 3 , the online backup method is described in detail as follows:

[0134] Step 301, obtain data information of the current node of the target database and data information of the historical backup of the target database; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of a transaction snapshot, and the data information of the historical backup of the target database includes second data.

[0135] Step 302: Generate a backup object list based on the first metadata.

[0136] Step 303: Determine a backup range based on the first data and the second data.

[0137] Step 304: lock the backup object of the target database, use the backup object list and the backup range as data to be backed up, and divide the data to be backed up into multiple parts for separate backing up.

[0138] The online backup process is as follows: Figure 4 As shown, the distribution component (task distribution module) distributes the backup task to multiple task execution modules (t1, t2, t3...t12). When performing backup, there are one or more task queues. The corresponding multiple task execution modules in the task queue perform backup in turn according to their own backup order (that is, the order in the task queue).

[0139] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0140] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An online backup device, characterized in that: include: Task distribution module and multiple task execution modules; The task distribution module is used to obtain data information of the current node of the target database and data information of the historical backup of the target database; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of transaction snapshot, and the data information of the historical backup of the target database includes second data; The task distribution module is further used to generate a backup object list based on the first metadata; and determine a backup range based on the first data and the second data; and lock the backup object of the target database, use the backup object list and the backup range as data to be backed up, and distribute the task of backing up the data to be backed up to multiple task execution modules; The task execution module is used to execute the received task; The task distribution module is also used for: Get the number of task execution modules and the amount of data to be backed up; Calculating the quotient of the amount of the to-be-backed-up data and the number of the task execution modules; If the quotient is an integer, the task amount of each task execution module to back up the data to be backed up is the same, and the task amount is the quotient; If the quotient is not an integer, the value of the quotient rounded down is used as the first component; Calculate the product of the floor-rounded value of the quotient and the number of the task execution modules to obtain a first calculation result; Calculating the difference between the amount of the to-be-backed up data and the first calculation result to obtain the amount of the to-be-backed up data that has not been allocated; According to a preset allocation order, the unallocated data to be backed up are allocated to the corresponding task execution modules, and the task execution modules allocated to the unallocated data to be backed up are recorded as first-category task execution modules, and the value of the second component of the first-category task execution modules is set to 1, and the task execution modules not allocated to the unallocated data to be backed up are recorded as second-category task execution modules, and the value of the second component of the second-category task execution modules is set to 0; For each task execution module, the sum of the first component and the second component of the task execution module is used as the task amount of the task execution module for backing up the data to be backed up.

2. The online backup device according to claim 1, characterized in that: The backup object list includes all the first metadata; the task distribution module is specifically used to: The changed data between the first data and the second data are compared to determine the backup range.

3. The online backup device according to claim 1, characterized in that: The online backup device also includes: a task recovery module; The task recovery module is used to replace the metadata at the recovery data location with the metadata in the backup data when receiving a data recovery instruction, and record the corresponding relationship between the data after recovery and the data before recovery.

4. The online backup device according to claim 1, characterized in that: The online backup device further includes: a task queue module; The task queue module is used to obtain the current memory of each task execution module, and calculate the maximum number of threads for each task execution module to back up data according to the current memory of each task execution module; The task execution module is further used to execute the received tasks according to the maximum number of threads of the task execution module.

5. The online backup device according to claim 4, characterized in that: The task queue module is also used for: Get the memory usage of each data to be backed up; For each task execution module, the current memory is calculated as the product of the current memory of the task execution module and the preset ratio, so as to obtain the maximum current memory of the task execution module for backup; The quotient of the maximum current memory used for backup by the task execution module and the memory occupation of each data to be backed up is calculated to obtain the maximum number of threads for simultaneously backing up data by the task execution module.

6. The online backup device according to claim 1, characterized in that: The online backup device further includes: a task checking module; The task check module is used to perform backup check and recovery check to obtain the results of the backup check and the recovery check; when the result of the backup check is passed and the result of the recovery check is passed, the task distribution module is controlled to evenly distribute the data to be backed up to multiple task execution modules.

7. The online backup device according to claim 6, characterized in that: The task inspection module is specifically used for: Check whether the database cluster is in read-only state, check whether the storage space of the backup location is sufficient, check whether the historical backup is complete, check whether the historical backup is valid, check whether there are DDL-related locks, check whether there is a full backup in the historical backup, check whether there is a backup object list, and check whether the backup-related information is updated; The backup check result is passed when the database cluster is in read-only state, the storage space of the backup location is sufficient, the historical backup is complete, the historical backup is valid, there is no DDL-related lock, there is a full backup in the historical backup, the backup object list exists, and there is updated backup-related information; Check whether the versions of the cluster being restored are consistent with those of the cluster being backed up, check whether the status of the cluster being restored is RECOVERY, check whether the storage space at the recovery location is sufficient, check whether the backups to the specified recovery point are all valid, check whether there are any ongoing read and write operations, and verify the backup data; The result of the recovery check is passed when the versions of the cluster to be restored are consistent with those of the cluster to be backed up, the status of the cluster to be restored is RECOVERY, the storage space of the recovery location is sufficient, the backups of the backup point to be restored are all valid, there are no ongoing read and write operations, and the checksum of the backup data is the same as the checksum in the information related to the backup; When the result of the backup check is passed and the result of the recovery check is passed, the task distribution module is controlled to evenly distribute the task of backing up the data to be backed up to a plurality of task execution modules.

8. The online backup device according to claim 1, characterized in that: The task execution module is also used for: When the backup of the task execution module is completed or an error occurs in the backup of the task execution module, a completion message or an error message is sent to the task distribution module; The online backup device also includes: a task visualization module; The task visualization module is used to visualize the process of backing up data of the task execution module based on the MVCC technology.

9. An online backup method, characterized in that: The method comprises: Acquire data information of a current node of a target database and data information of a historical backup of the target database; wherein the data information of the current node of the target database includes first metadata and first data, the first data is obtained by means of a transaction snapshot, and the data information of the historical backup of the target database includes second data; Based on the first metadata, generating a backup object list; Determine a backup scope based on the first data and the second data; Locking the backup object of the target database, taking the backup object list and the backup range as data to be backed up, and dividing the data to be backed up into multiple parts for separate backing up; The method further comprises: Get the number of task execution modules and the amount of data to be backed up; Calculating the quotient of the amount of the to-be-backed-up data and the number of the task execution modules; If the quotient is an integer, the task amount of each task execution module to back up the data to be backed up is the same, and the task amount is the quotient; If the quotient is not an integer, the value of the quotient rounded down is used as the first component; Calculate the product of the floor-rounded value of the quotient and the number of the task execution modules to obtain a first calculation result; Calculating the difference between the amount of the to-be-backed up data and the first calculation result to obtain the amount of the to-be-backed up data that has not been allocated; According to a preset allocation order, the unallocated data to be backed up are allocated to the corresponding task execution modules, and the task execution modules allocated to the unallocated data to be backed up are recorded as first-category task execution modules, and the value of the second component of the first-category task execution modules is set to 1, and the task execution modules not allocated to the unallocated data to be backed up are recorded as second-category task execution modules, and the value of the second component of the second-category task execution modules is set to 0; For each task execution module, the sum of the first component and the second component of the task execution module is used as the task amount of the task execution module for backing up the data to be backed up.