A data backup method in a database

By adopting a separate storage architecture between metadata and business data in the database, only backing up metadata and archiving business data, the problem of frequent backup of large data in the database is solved, and the storage cost and time cost are reduced.

CN115328696BActive Publication Date: 2025-08-26ALIBABA CLOUD COMPUTING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210901272.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-28
Publication Date
2025-08-26
Estimated Expiration
2042-07-28

AI Technical Summary

Technical Problem

The data in the database is large and has high security requirements. Frequent backups consume a lot of storage resources and time costs.

Method used

The metadata and business data are separated storage architecture, and only the metadata is backed up locally in the database, and the corresponding business data is archived in the remote storage system, and business data is archived when the local target metadata is deleted.

Benefits of technology

Reduces storage costs and time costs during database backup and improves data backup efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115328696B_ABST
    Figure CN115328696B_ABST
Patent Text Reader

Abstract

This specification provides a method and apparatus for backing up data in a database. The method includes: in response to a backup event for the database, obtaining metadata to be backed up that is stored locally in the database, and backing up the obtained metadata; in response to a user's deletion instruction for target metadata, deleting the target metadata; and archiving business data corresponding to the target metadata that is stored in a remote storage system corresponding to the database, and deleting the business data after the archiving is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of database technology. More specifically, the embodiments of this specification relate to a method and device for backing up data in a database. Background Art

[0002] This section is intended to provide a background or context to the embodiments of the present specification that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.

[0003] In the field of data security, backup and recovery functions are often used to ensure data security and to address situations such as data loss and the need for data recovery. Databases typically store large amounts of data and have high security requirements, necessitating frequent backups. Consequently, database backup and recovery typically consumes significant storage resources and takes a considerable amount of time. Summary of the Invention

[0004] To overcome the problems existing in the related art, this specification provides the following methods and devices.

[0005] In a first aspect of the embodiments of this specification, a method for backing up data in a database is provided, the method comprising:

[0006] In response to a backup event for a database, obtaining metadata to be backed up that is stored locally in the database, and performing backup processing on the obtained metadata;

[0007] In response to a user's deletion instruction for target metadata, deleting the target metadata; and

[0008] Archiving processing is performed on the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and after the archiving processing is completed, the business data is deleted.

[0009] In a second aspect of the embodiments of this specification, a data backup device in a database is provided, the device comprising:

[0010] A data backup unit is configured to, in response to a backup event for a database, obtain metadata to be backed up stored locally in the database, and perform backup processing on the obtained metadata;

[0011] a data archiving unit configured to delete the target metadata in response to a user's deletion instruction for the target metadata; and

[0012] Archiving processing is performed on the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and after the archiving processing is completed, the business data is deleted.

[0013] In a third aspect of the embodiments of this specification, a storage medium is provided; the storage medium stores a computer program, which, when executed, implements the steps of the following method:

[0014] In response to a backup event for a database, obtaining metadata to be backed up that is stored locally in the database, and performing backup processing on the obtained metadata;

[0015] In response to a user's deletion instruction for target metadata, deleting the target metadata; and

[0016] Archiving processing is performed on the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and after the archiving processing is completed, the business data is deleted.

[0017] In a fourth aspect of the embodiments of this specification, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the following method is implemented:

[0018] In response to a backup event for a database, obtaining metadata to be backed up that is stored locally in the database, and performing backup processing on the obtained metadata;

[0019] In response to a user's deletion instruction for target metadata, deleting the target metadata; and

[0020] The business data corresponding to the target metadata and stored in the remote storage system corresponding to the database is archived, and after the archiving process is completed, the business data is deleted. The above implementation of this specification has at least the following beneficial effects:

[0021] In the above technical solution, since the database adopts a storage architecture that only stores metadata locally in the database node and stores the business data corresponding to the metadata in a remote storage system, when backing up data in the above database, it is only necessary to back up the metadata stored locally in the database node, and only archive the corresponding business data when the metadata is deleted, and restore the archived technical data when the data is restored, without the need to perform a full backup of the business data stored in the remote storage system, thereby greatly reducing the storage cost and time cost consumed when backing up the database data. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0023] Figure 1 Schematically shows a schematic diagram of the architecture of a method for backing up data in a database according to an embodiment of this specification;

[0024] Figure 2 The following schematically shows a flow chart of a method for backing up data in a database according to an embodiment of the present specification;

[0025] Figure 3 The following schematically shows a flow chart of another method for backing up data in a database according to an embodiment of the present specification;

[0026] Figure 4 The following schematically illustrates a metadata backup process in a method for backing up data in a database according to an embodiment of the present specification;

[0027] Figure 5 A schematic diagram schematically illustrates a data recovery process in a data backup method in a database according to an embodiment of the present specification;

[0028] Figure 6 A schematic diagram schematically illustrates a data archiving process in a data backup method in a database according to an embodiment of the present specification;

[0029] Figure 7 A block diagram schematically shows a data backup device in a database according to an embodiment of the present specification;

[0030] Figure 8 A hardware structure diagram of a computer device in which a method for backing up data in a database according to an embodiment of the present specification is schematically shown.

[0031] In the drawings, the same or corresponding reference numerals denote the same or corresponding parts. DETAILED DESCRIPTION

[0032] The principles and spirit of this specification will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided solely to enable those skilled in the art to better understand and implement this specification and are not intended to limit the scope of this specification in any way. Rather, these embodiments are provided to make this specification more thorough and complete, and to fully convey the scope of this specification to those skilled in the art.

[0033] Those skilled in the art will appreciate that the embodiments of this specification may be implemented as a system, apparatus, device, method, or computer program product. Therefore, this specification may be implemented in the following forms: entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0034] In the field of data security, it's common to regularly back up important data so that it can be restored to its state when needed. In the database field, data security requirements are often high, so frequent backups are necessary. However, databases typically contain large amounts of data, and frequently backing up large amounts of data consumes significant storage resources and time.

[0035] In view of this, this specification proposes a method for backing up data in a database.

[0036] The solution of this specification is described in detail below with reference to the accompanying drawings.

[0037] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of a data backup system in a database provided by an exemplary embodiment. Figure 1 As shown, the system may include a network 10, a server 11, and several electronic devices, such as a mobile phone 12, a mobile phone 13, and a mobile phone 14.

[0038] Server 11 can be a physical server containing an independent host, or it can be a virtual server hosted by a host cluster, a cloud server, etc. Mobile phones 12-14 are just one type of electronic device that users can use. In fact, users can obviously also use electronic devices such as tablet devices, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), etc., and one or at least one embodiment of this specification is not limited to this. Network 10 can include various types of wired or wireless networks.

[0039] In one embodiment, server 11 can cooperate with mobile phones 12-14; mobile phones 12-14 can accept user operations and upload the received commands and files to server 11 via network 10, and server 11 can then process the files based on the solutions of this specification. In another embodiment, mobile phones 12-14 can independently implement the solutions of this specification; mobile phones 12-14 can accept user operations and process the received commands and files based on the solutions of this specification to achieve data backup in the database.

[0040] See Figure 2 , Figure 2 This is a flowchart of a data backup method in a database provided by an exemplary embodiment. The method is applied to a processing device. The processing device can be Figure 1 The server 11 or mobile phones 12-14 etc. are shown.

[0041] The method comprises the following steps:

[0042] Step 202: In response to a backup event for a database, metadata to be backed up stored locally in the database is obtained, and backup processing is performed on the obtained metadata.

[0043] In the embodiment shown in this specification, the data stored in the database includes business data stored in a remote storage system, and metadata corresponding to the business data stored locally in the database.

[0044] The above-mentioned remote storage system is used to store business data, and the database can access the business data stored in the above-mentioned remote storage system.

[0045] It should be noted that the above-mentioned business data may specifically include any type of user data stored in the above-mentioned database based on specific business needs of the user.

[0046] The data type of the above-mentioned business data is usually related to the business type carried by the processing device where the database is located, and is not particularly limited in this specification.

[0047] For example, in one example, if the aforementioned business is a cloud business, the aforementioned business data may specifically be cloud data related to the cloud business stored by the user in a database on the cloud service side. For example, the aforementioned cloud business may specifically be an OSS (Object Storage Service) service provided to users by a cloud service platform, and the aforementioned database may be an OSS database on the cloud service platform. In this case, the aforementioned cloud data may specifically include unstructured data such as photos and videos uploaded by users to the OSS database for storage.

[0048] The metadata includes data for describing the details of the database and data for describing business data corresponding to the metadata.

[0049] The database may obtain a backup event for the database to back up the data in the database.

[0050] The above-mentioned backup event for the database can be a backup event triggered based on a preset backup cycle, or a backup event triggered by a database management program or user, or a backup event triggered by detecting a specific change in the data in the above-mentioned database. This specification does not specifically limit this.

[0051] After obtaining the above backup event, the database can obtain the locally stored metadata to be backed up.

[0052] The metadata to be backed up refers to the portion of metadata that needs to be backed up, which can usually be specified by the backup event, or can be preset to all metadata, or a specified portion of metadata, etc. This specification does not specifically limit this.

[0053] This specification does not specifically limit the target location for storing the backup of the metadata to be backed up. For example, depending on actual needs, the backup can be stored locally on the computing node, in the remote storage system, or in another designated storage device.

[0054] Typically, when backing up the metadata, the backup time is recorded.

[0055] By backing up the metadata to be backed up, when the metadata needs to be restored, the metadata can be restored to a state corresponding to a specified recovery time.

[0056] Step 204, in response to the user's deletion instruction for the target metadata, delete the target metadata; and archive the business data corresponding to the target metadata stored in the remote storage system corresponding to the database, and delete the business data after the archiving process is completed.

[0057] Due to the architecture of separate storage of metadata and business data, when some metadata in the local database is deleted, the corresponding business data stored in the remote storage system will not be deleted synchronously.

[0058] Usually, after the metadata is deleted, the corresponding business data will no longer be used; therefore, when deleting the local target metadata, the corresponding business data in the remote storage system can be deleted.

[0059] However, since the local target metadata may be restored after being deleted, and the corresponding business data needs to be used again, when the target metadata is deleted, the business data corresponding to the target metadata cannot be directly deleted.

[0060] Before deleting the business data corresponding to the target metadata, the business data to be deleted in the remote storage system must be archived. Figure 3 , Figure 3 This is a flowchart of a data backup method in a database provided by an exemplary embodiment. The method is applied to a processing device. The processing device can be Figure 1 The server 11 or mobile phones 12-14 shown in FIG. The method includes the following steps:

[0061] Step 302: Acquire a triggered backup event for the database.

[0062] In the embodiment shown in this specification, the database includes a node cluster composed of multiple database nodes. The data stored in the database includes business data stored in a remote storage system and metadata corresponding to the business data stored in the database nodes.

[0063] In an illustrative embodiment described in this specification, the database employs a storage-computing separation architecture, includes a cloud-native data warehouse, and includes computing nodes that perform computations based on business data stored in the remote storage system. These computing nodes can perform large-scale parallel processing of data in the database.

[0064] A cloud-native data warehouse is a data warehouse implemented based on shared resources on the cloud, such as the OSS (Object Storage Service) storage system and S3 (Simple Storage Service).

[0065] The above-mentioned remote storage system is used to store business data and is shared by multiple database nodes in the above-mentioned node cluster. Each database node can access the business data stored in the above-mentioned remote storage system.

[0066] In an exemplary embodiment shown in this specification, the remote storage system includes an OSS storage system deployed in the cloud.

[0067] The metadata includes data for describing the details of the database and data for describing business data corresponding to the metadata.

[0068] The database may obtain a backup event for the database to back up the data in the database.

[0069] The above-mentioned backup event for the database can be a backup event triggered based on a preset backup cycle, or a backup event triggered by a backup instruction issued by a database management program or a user, or a backup event triggered by detecting a specific change in the data in the above-mentioned database. This specification does not specifically limit this.

[0070] In an exemplary embodiment shown in this specification, the above-mentioned backup event is a backup event that is triggered based on a preset backup period.

[0071] In an illustrative embodiment shown in this specification, the above-mentioned backup events include a first backup event for the above-mentioned metadata triggered based on a preset first backup cycle, and a second backup event for the log file corresponding to the above-mentioned metadata triggered based on a preset second backup cycle; usually, the above-mentioned second backup cycle is smaller than the above-mentioned first backup cycle.

[0072] In a data node, the amount of metadata to be backed up may be large, and the backup frequency is high. To further reduce the storage space and time consumed by the backup, the frequency of metadata backup can be reduced. Instead of backing up the metadata, the log files corresponding to the metadata with a significantly smaller data volume can be backed up.

[0073] For example, the RPO (recovery point objective) indicator in a certain database is 1 hour, that is, the maximum backup cycle is 1 hour. If the metadata of the computing nodes of the database is backed up once every hour, more resources will be consumed. If the metadata backup cycle is extended to 48 hours, the log files corresponding to the metadata will be backed up every hour. Because the data volume of the log files is much smaller than the corresponding metadata, the resources consumed by the backup will be greatly reduced.

[0074] Step 304: In response to the acquired first backup event, the metadata to be backed up stored locally in the database is acquired, and backup processing is performed on the acquired metadata.

[0075] After obtaining the first backup event, each database node may respectively obtain the metadata to be backed up that is stored locally.

[0076] The metadata to be backed up refers to the portion of metadata that needs to be backed up, which can usually be specified by the backup event, or can be preset to all metadata, or a specified portion of metadata, etc. This specification does not specifically limit this.

[0077] The log file records the modification details of the corresponding metadata after the last backup is completed. The modification may include adding, rewriting, deleting, and other operations that can change the metadata.

[0078] After obtaining the metadata to be backed up, it can be backed up. This specification does not specifically limit the target storage location for the metadata to be backed up. For example, depending on actual needs, the backup can be stored locally on the computing node, in the remote storage system, or in another designated storage device.

[0079] Step 306: In response to the acquired second backup event, a log file corresponding to the metadata is acquired, and a backup process is performed on the acquired log file.

[0080] After obtaining the second backup event, each database node may respectively obtain the locally stored log file corresponding to the metadata to be backed up.

[0081] The metadata to be backed up refers to the portion of metadata that needs to be backed up, which can usually be specified by the backup event, or can be preset to all metadata, or a specified portion of metadata, etc. This specification does not specifically limit this.

[0082] The log file records the modification details of the corresponding metadata after the last backup is completed. The modification may include adding, rewriting, deleting, and other operations that can change the metadata.

[0083] After obtaining the metadata to be backed up and its corresponding log files, they can be backed up. This specification does not specifically limit the target location for storing the backup of the metadata to be backed up and its corresponding log files. For example, depending on actual needs, the backup can be stored locally on the computing node, in the remote storage system, or in another designated storage device.

[0084] By backing up the metadata to be backed up and the log files corresponding to the metadata to be backed up, the metadata can be restored to a state corresponding to a specified recovery time when the metadata needs to be restored.

[0085] In one embodiment shown in this specification, the backup of the obtained metadata is stored in the remote storage system, such as an OSS storage system.

[0086] In one embodiment shown in this specification, the backup storage of the above-mentioned obtained metadata to the above-mentioned remote storage system includes: writing the above-mentioned metadata into the data pipeline; reading the above-mentioned metadata from the above-mentioned data pipeline, and using the thread pool to upload the above-mentioned metadata fragments in parallel to the above-mentioned remote storage system.

[0087] like Figure 4 As shown, Figure 4 This is a schematic diagram of a metadata backup process in a data backup method in a database according to an embodiment of this specification.

[0088] The metadata backup in each data node can be written into the data pipeline. Since the amount of metadata may be large, a thread pool can be used to accelerate the process of transmitting the metadata backup to the remote storage system.

[0089] The thread pool can upload the metadata backup obtained from the above data pipeline to the remote storage system in a concurrent and fragmented manner, and can speed up the backup upload by properly allocating multi-threaded resources.

[0090] Step 308: After the metadata backup is completed, it is determined whether the storage time of the existing metadata backup exceeds the preset first storage time; if so, the metadata backup that exceeds the preset first storage time is deleted.

[0091] To save storage space for backups, you can delete backups of metadata that have been saved for too long.

[0092] For example, a preset first storage period can be set. After the metadata backup is completed, it can be determined whether the storage period of the existing metadata backup exceeds the above first storage period, and the metadata backup whose storage period exceeds the above first storage period can be deleted.

[0093] For another example, the metadata retention period can be controlled by the number of metadata backups saved; for example, a maximum number of metadata backups saved can be preset, and when the number of metadata backups saved exceeds the maximum number, the metadata backup with the longest retention period can be deleted.

[0094] For another example, the storage time of metadata can be controlled by the storage space occupied by the backup of the saved metadata; for example, the maximum storage space occupied by the backup of the saved metadata can be preset. When the storage space occupied by the backup of the saved metadata exceeds the above maximum storage space, the backup of the metadata with the longest storage time can be deleted.

[0095] Step 310: In response to a user's deletion instruction for target metadata, the target metadata is deleted; and the business data corresponding to the target metadata stored in the remote storage system corresponding to the database is archived. After the archiving process is completed, the business data is deleted. Due to the architecture of separate storage of metadata and business data, when certain metadata on the database node is deleted, the corresponding business data stored in the remote storage system is not deleted synchronously.

[0096] Usually, after the metadata is deleted, the corresponding business data will no longer be used; therefore, when deleting the local target metadata, the corresponding business data in the remote storage system can be deleted.

[0097] However, since the local target metadata may need to be restored after being deleted, so that the corresponding business data needs to be used again, when the target metadata is deleted, the business data corresponding to the above target metadata cannot be directly deleted.

[0098] Before deleting the business data corresponding to the target metadata, the business data corresponding to the target metadata stored in the remote storage system corresponding to the database may be archived.

[0099] The above-mentioned archiving process may be to directly archive the business data that needs to be archived, or to archive the business data that needs to be archived after performing specific processing, which is not specifically limited in this specification.

[0100] In one embodiment shown in this specification, the business data that needs to be archived may be compressed before being archived, so as to save the space required for archiving the original output.

[0101] Step 312: In response to the backup recovery instruction, obtain the recovery time included in the backup recovery instruction, and obtain metadata corresponding to the most recent backup from the recovery time, and a log file corresponding to the most recent backup after the recovery time.

[0102] When the data in the above database needs to be restored, the user can send a backup and restore instruction to restore the metadata to the state at the specified restoration time.

[0103] The above-mentioned recovery instruction may include a recovery time, or also called a recovery point; in particular, when the above-mentioned recovery instruction does not include a recovery time, or the recovery time is a default value, the recovery time may be specified as a preset recovery time, such as the most recent recovery time, or the time since the last metadata backup, etc. This specification does not specifically limit this.

[0104] The aforementioned recovery time includes the consistency recovery time. Because the order in which transactions are submitted and processed by different database nodes within the node cluster may differ, the states of the nodes are synchronized only after the transaction is committed and processed. The point in time when the states of the nodes are synchronized is the consistency recovery time. In this description, unless otherwise specified, the recovery time generally refers to the consistency recovery time.

[0105] Step 314: replay the obtained metadata based on the obtained log file until the metadata is restored to the data version corresponding to the restoration moment.

[0106] After receiving the backup and restore command, each database node can obtain a backup of the metadata corresponding to the restore time and a backup of the corresponding log file. The backup of the metadata corresponding to the restore time can be the metadata most recently backed up before or after the restore time, and the log file can typically be the log file most recently backed up after the restore time.

[0107] The metadata is replayed according to the log file until the metadata is restored to a data version corresponding to the restoration moment.

[0108] In particular, when there is a backup of metadata with the same backup time as the restoration time, there is no need to replay the metadata based on the log file.

[0109] In an exemplary embodiment shown in this specification, the restore instruction indicates restoring the metadata to a new cluster;

[0110] Before replaying the obtained backup of the metadata based on the obtained backup of the log file, the method further includes:

[0111] Creating a recovery cluster consisting of the same number of new database nodes according to the number of database nodes included in the node cluster, wherein the new database nodes in the recovery cluster correspond one-to-one to the database nodes in the node cluster;

[0112] The backup of the metadata and the backup of the log files in each database node in the node cluster are respectively transmitted to the corresponding new database node in the recovery cluster.

[0113] like Figure 5 As shown, Figure 5 It is a schematic diagram of a data recovery process in a data backup method in a database according to an embodiment of the present specification.

[0114] When metadata needs to be restored to a new cluster, a recovery cluster corresponding to the above node cluster can be created first; the number of database nodes in the above recovery cluster is equal to the number of database nodes in the above node cluster, and the database nodes in the recovery cluster correspond one-to-one to the database nodes in the above node cluster.

[0115] After the recovery cluster is created, each database node in the recovery cluster can obtain a backup of the metadata and log files corresponding to the corresponding database node in the node cluster according to the recovery time.

[0116] In each database node of the recovery cluster, the above metadata is replayed based on the log file corresponding to the metadata backup, and the metadata is restored to the data version corresponding to the recovery moment, so that in each database node of the recovery cluster, the metadata is restored to the version at the recovery moment.

[0117] Step 316: Based on the archived business data, the deleted business data is restored to the state corresponding to the restoration time.

[0118] Based on the archived business data, the deleted business data is restored to the state corresponding to the above-mentioned restoration time, so that the restored metadata can correctly access its corresponding business data.

[0119] In an exemplary implementation shown in this specification, since the business data corresponding to the metadata deleted before the above-mentioned restoration moment is no longer needed, only the business data archived after the above-mentioned restoration moment can be restored.

[0120] For example, if the business data to be restored has been compressed during archiving, it may be decompressed accordingly first.

[0121] like Figure 6 As shown, Figure 6 It is a schematic diagram of a data archiving process in a data backup method in a database according to an embodiment of the present specification.

[0122] The business data corresponding to a certain metadata is table t1, which initially contains eight OSS files f1, f2, ..., f8. This is the recovery time rp1.

[0123] Afterward, the user performs an operation on table t1, such as a vacuun merge. This deletes some data from table t1 and merges the eight OSS files into four new OSS files, f'1, f'2, f'3, and f'4. This is recovery time rp2. Because some business data has been deleted, it's necessary to archive the business data—that is, the state of table t1 before the data was deleted, i.e., the state at recovery time rp1. After archiving, the OSS files in table t1 are renamed f1.done...f8.done, and the original OSS files f1, f2, ..., f8 are deleted.

[0124] Afterwards, the user performs some operations on table t1. For example, after the insert operation, OSS files f'5 and f'6 are inserted into table 1, but no data is deleted. In this case, there is no need to archive the previous business data. This is the recovery time rp3.

[0125] Later, the user performs an operation on table t1, such as a vacuum merge, which deletes some data from table 1. This is recovery time rp4. Because some business data has been deleted, it is necessary to archive the business data—that is, the state of table t1 before the data was deleted, i.e., the state at recovery time rp3. After renaming each OSS file in table t1 to f'1.done...f'6.done and archiving them, delete the original OSS files f'1, f'2, ..., f'6.

[0126] When the backup recovery instruction is obtained and the metadata is restored to the recovery time rp1, the archive of the business data corresponding to the recovery time rp1, that is, the archive file f1.done...f8.done, can be restored.

[0127] Step 318: According to a preset judgment cycle, it is regularly judged whether the archives of the existing business data exceed the preset second storage time, and the archives of the business data that exceed the preset second storage time are deleted.

[0128] Similarly, in order to save storage space required for archiving, you can delete the archives of business data that have been saved for too long;

[0129] For example, a preset second storage period can be set. Every preset judgment period, it can be determined whether the storage period of the existing business data archives exceeds the above second storage period, and the archives of business data whose storage period exceeds the above second storage period can be deleted.

[0130] For another example, the storage duration of business data can be controlled by the number of archives of saved business data; for example, the maximum number of archives of saved business data can be preset, and when the archives of saved business data exceed the above maximum number, the archive of business data with the longest storage duration can be deleted.

[0131] For another example, the storage time of business data can be controlled by the storage space occupied by the archives of saved business data; for example, the maximum storage space occupied by the archives of saved business data can be preset. When the storage space occupied by the archives of saved business data exceeds the above maximum storage space, the archives of the business data with the longest storage time can be deleted.

[0132] In an exemplary embodiment of this specification, a method for backing up data in a database is also provided. Figure 7 , Figure 7 It is a block diagram of a data backup method in a database according to an embodiment of the present specification.

[0133] The database includes a node cluster consisting of multiple database nodes; the data stored in the database includes business data stored in a remote storage system and metadata corresponding to the business data stored locally in the database node; the method is applied to the database node; the apparatus includes:

[0134] The data backup unit 710 is configured to, in response to a backup event for a database, obtain metadata to be backed up stored locally in the database, and perform backup processing on the obtained metadata;

[0135] The data archiving unit 720 is configured to delete the target metadata in response to a user's deletion instruction for the target metadata; and

[0136] Archiving processing is performed on the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and after the archiving processing is completed, the business data is deleted.

[0137] Optionally, the device further includes:

[0138] Data recovery unit 730: configured to, in response to a backup recovery instruction, obtain a recovery time included in the backup recovery instruction, and obtain metadata corresponding to the most recent backup from the recovery time, as well as a log file corresponding to the most recent backup after the recovery time;

[0139] Based on the obtained log file, the obtained metadata is replayed until the metadata is restored to a data version corresponding to the restoration moment.

[0140] Optionally, the data backup unit 710 is specifically used to obtain the locally stored metadata to be backed up; and the log file corresponding to the metadata, and to back up the obtained metadata and the log file; wherein the log file records the modification details corresponding to the modifications to the metadata after the last backup is completed.

[0141] Optionally, the backup event is a backup event that is triggered based on a preset backup cycle; the backup event includes a first backup event for the metadata triggered based on a preset first backup cycle; and a second backup event for the log file triggered based on a preset second backup cycle; wherein the cycle length corresponding to the second backup cycle is shorter than the cycle length corresponding to the first backup cycle;

[0142] Correspondingly, the data backup unit 710 is specifically configured to obtain locally stored metadata to be backed up in response to the obtained first backup event, and perform backup processing on the obtained metadata; and

[0143] In response to the acquired second backup event, a log file corresponding to the metadata is acquired, and a backup process is performed on the acquired log file.

[0144] Optionally, the data backup unit 710 is specifically configured to back up the metadata to the remote storage system.

[0145] Optionally, the metadata backup unit 710 is specifically configured to write the metadata into a data pipeline; read the metadata from the data pipeline, and use a thread pool to upload the metadata fragments in parallel to the remote storage system.

[0146] Optionally, the device further includes:

[0147] The first cleaning unit 740 is configured to determine whether the storage duration of the existing metadata backups exceeds a preset first storage duration after the metadata backup is completed, and delete the metadata backups that exceed the preset first storage duration.

[0148] The service data is optional, and the device further includes:

[0149] The second cleaning unit 750 is used to periodically determine whether the archived business data exceeds a preset second retention period according to a preset judgment period;

[0150] If so, delete the archive of the business data that exceeds the preset second storage time.

[0151] Optionally, the database includes a node cluster consisting of multiple database nodes; the metadata is stored in the above database nodes; the restoration instruction instructs to restore the metadata to a new cluster; and the apparatus further includes:

[0152] The recovery cluster unit 760 is used to create a recovery cluster consisting of the same number of new database nodes according to the number of database nodes included in the node cluster, wherein the new database nodes in the recovery cluster correspond one-to-one to the database nodes in the node cluster; and respectively transmit the backup of the metadata and the backup of the log files in each database node in the node cluster to the corresponding new database nodes in the recovery cluster.

[0153] Optionally, the database adopts a storage and computing separation architecture; the database includes a cloud-native data warehouse; and the database nodes include computing nodes that perform calculations based on the business data stored in the remote storage system.

[0154] Optionally, the remote storage system includes an OSS storage system deployed in the cloud.

[0155] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0156] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on at least one network unit. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0157] In the exemplary embodiments of this specification, an embodiment of a device and a terminal to which the device is applied is also provided.

[0158] The embodiments of the device of this specification can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented through software, hardware, or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. From the hardware level, if Figure 8 As shown, Figure 8 This is a hardware structure diagram of a computer device 80 where an apparatus according to an embodiment of the present specification is located, except Figure 8 In addition to the processor 810, memory 830, network interface 820, and non-volatile memory 840 shown, the server or electronic device where the device is located in the embodiment may also include other hardware according to the actual function of the computer device, which will not be described in detail.

[0159] In exemplary embodiments of this specification, a computer-readable storage medium is also provided, storing a program product capable of implementing the aforementioned methods of this specification. In some possible embodiments, various aspects of this specification may also be implemented in the form of a program product comprising program code. When the program product is executed on a terminal device, the program code is configured to cause the terminal device to execute the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this specification.

[0160] According to embodiments of this specification, a program product for implementing the above-described method may be a portable compact disc read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of this specification is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0161] The program product may employ any combination of one or at least one readable medium. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or at least one wire, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0162] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0163] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0164] Program code for performing the operations of this specification may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, and the like, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0165] Although this specification contains many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of specific embodiments of specific inventions. Certain features described in at least one embodiment within this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in at least one embodiment or in any suitable sub-combination. In addition, although features may function in certain combinations as described above and even initially claimed as such, one or at least one feature from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of the sub-combination.

[0166] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or that all illustrated operations be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system units and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into at least one software product.

[0167] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the particular order shown or sequential sequence to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0168] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A method for backing up data in a database, the method comprising: In response to a backup event for a database, obtaining metadata to be backed up that is stored locally in the database, and performing backup processing on the obtained metadata; In response to a user's deletion instruction for target metadata, deleting the target metadata; as well as, Archiving the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and deleting the business data after the archiving is completed; The acquiring metadata to be backed up stored locally in the database and performing backup processing on the acquired metadata includes: Obtaining metadata to be backed up that is stored locally in the database; and a log file corresponding to the metadata, and backing up the obtained metadata and the log file; wherein the log file records modification details corresponding to modifications to the metadata that occurred after the last backup was completed; The backup event is a backup event that is triggered based on a preset backup cycle; the backup event includes a first backup event for the metadata triggered based on a preset first backup cycle; and a second backup event for the log file triggered based on a preset second backup cycle; wherein the cycle length corresponding to the second backup cycle is shorter than the cycle length corresponding to the first backup cycle; The method further comprises: In response to a backup and restore instruction, obtaining a restore time included in the backup and restore instruction, and obtaining metadata corresponding to a backup most recent to the restore time, and a log file corresponding to a backup most recent after the restore time; Based on the obtained log file, the obtained metadata is replayed until the metadata is restored to a data version corresponding to the restoration moment.

2. The method according to claim 1, In response to the acquired backup event, acquiring locally stored metadata to be backed up; and a log file corresponding to the metadata, and backing up the obtained metadata and the log file, including: In response to the acquired first backup event, acquiring locally stored metadata to be backed up, and performing backup processing on the acquired metadata; as well as, In response to the acquired second backup event, a log file corresponding to the metadata is acquired, and a backup process is performed on the acquired log file.

3. The method according to claim 1, The backing up of the obtained metadata includes: The metadata is fragmented, and the metadata fragments obtained after the fragmentation are backed up to the remote storage system in a parallel uploading manner.

4. The method according to claim 1, further comprising: After the metadata backup is completed, it is determined whether the storage time of the existing metadata backup exceeds the preset first storage time, and the metadata backup that exceeds the preset first storage time is deleted.

5. The method according to claim 1, further comprising: Based on the backup of the log file obtained, the backup of the metadata obtained is replayed until the metadata is restored to the data version corresponding to the recovery moment, and then based on the archived business data, the deleted business data is restored to the state corresponding to the recovery moment.

6. The method according to claim 1, further comprising: According to the preset judgment cycle, regularly judge whether the archive of existing business data exceeds the preset second retention period; If so, delete the archive of the business data that exceeds the preset second retention period.

7. The method according to claim 1, The database includes a node cluster consisting of multiple database nodes; the metadata is stored locally on the database nodes; the recovery instruction instructs to restore the metadata to a new cluster; The method further comprises: replaying the obtained metadata until the metadata is restored to a data version corresponding to the restoration moment, and creating a recovery cluster consisting of the same number of new database nodes as the number of database nodes included in the node cluster, wherein the new database nodes in the recovery cluster correspond one-to-one to the database nodes in the node cluster; The backup of the metadata and the backup of the log files in each database node in the node cluster are respectively transmitted to the corresponding new database node in the recovery cluster.

8. The method according to claim 1, The remote storage system includes an OSS storage system deployed in the cloud.

9. The method according to claim 7, The database adopts a storage and computing separation architecture; the database includes a cloud-native data warehouse; the database nodes include computing nodes that perform calculations based on the business data stored in the remote storage system.

10. A data backup device in a database, the device comprising: A data backup unit is configured to, in response to a backup event for a database, obtain metadata to be backed up stored locally in the database, and perform backup processing on the obtained metadata; A data archiving unit: configured to delete the target metadata in response to a deletion instruction from a user; as well as, Archiving the business data corresponding to the target metadata and stored in a remote storage system corresponding to the database, and deleting the business data after the archiving is completed; The acquiring metadata to be backed up stored locally in the database and performing backup processing on the acquired metadata includes: Obtaining metadata to be backed up that is stored locally in the database; and a log file corresponding to the metadata, and backing up the obtained metadata and the log file; wherein the log file records modification details corresponding to modifications to the metadata that occurred after the last backup was completed; The backup event is a backup event that is triggered based on a preset backup cycle; the backup event includes a first backup event for the metadata triggered based on a preset first backup cycle; and a second backup event for the log file triggered based on a preset second backup cycle; wherein the cycle length corresponding to the second backup cycle is shorter than the cycle length corresponding to the first backup cycle; The device further comprises: In response to a backup and restore instruction, obtaining a restore time included in the backup and restore instruction, and obtaining metadata corresponding to a backup most recent to the restore time, and a log file corresponding to a backup most recent after the restore time; Based on the obtained log file, the obtained metadata is replayed until the metadata is restored to a data version corresponding to the restoration moment.

11. A storage medium having a computer program stored thereon, which is configured to implement the steps of the method according to any one of claims 1 to 9 when the computer program is executed.

12. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the following method is implemented: wherein, when the processor executes the program, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Backup recovery system and method for modern applications

    CN111581017A

  • Using a metadata image of a file system and archive instance to backup data objects in the file system

    US20140074787A1