Method and device for backing up and recovering graphs in graph database
By judging the data magnitude in the graph database and adopting different backup and recovery strategies, the problem of high backup and recovery costs in the existing technology is solved, and efficient graph database backup and recovery is achieved.
Patent Information
- Application Number
- CN202411851596.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-28
AI Technical Summary
In the graph database, the existing technology lacks effective backup and recovery methods, which leads to the need to re-model, governance and storage of graph data when the environment of rapid deployment or changes in stock projects, resulting in high labor and time costs.
Provide a backup and recovery method of graphs in graph database. By judging the data magnitude of the target graph, different backup and recovery strategies are adopted. For small data scenarios, the business metadata, graph model and graph data files are exported simultaneously for backup; for big data scenarios, the incremental snapshot of graph data is exported and the backup is regularly. During recovery, the corresponding files and snapshots are loaded according to the data order.
It improves the backup and recovery speed of graphs in graph database, reduces resource consumption in big data scenarios, and reduces labor and time costs.
Smart Images

Figure CN119718782A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for backing up and restoring a graph in a graph database. Background Art
[0002] With the rapid development of information technology, graph databases, as a type of database that stores data in a graph structure, have shown great application potential in fields such as big data processing and complex relationship analysis.
[0003] In related technologies, JanusGraph, as a graph database that stores data in the form of attribute graphs, can support rapid query and exploration of graph data with billions of nodes and tens of billions of edges in big data scenarios.
[0004] However, before graph data is stored in the database, it must first go through a series of tedious and time-consuming pre-processes such as graph data modeling, governance, and storage. When quickly deploying and demonstrating POC (Proof of Concept) projects, or when the deployment environment of existing projects changes and historical data needs to be migrated, if there is no technical solution for backup and recovery, the graph data needs to be re-modeled, governed, and stored in the database. However, the manpower and time costs of re-storing graph data are too high, which is often unacceptable in reality. In this context, the backup and recovery strategy of the graph is particularly important. Summary of the invention
[0005] The present application provides a method and device for backing up and restoring a graph in a graph database, which can execute different backup and recovery strategies for the graph in small data (deployment of POC projects) and big data scenarios.
[0006] In a first aspect, an embodiment of the present application provides a method for backing up a graph in a graph database, the method comprising:
[0007] Determine whether the data level of the target graph is lower than the preset data level;
[0008] If yes, the business metadata file, graph model file and graph data file of the target graph are synchronously exported from the graph database and stored in the backup storage path;
[0009] If not, the business metadata file, graph model file and full snapshot of the graph data at the current moment of the target graph are synchronously exported from the graph database and stored in the backup storage path; starting from the current moment, every time a preset backup time point is reached, an incremental snapshot of the graph data of the target graph at the current backup time point is exported from the graph database and stored in the backup storage path.
[0010] In combination with the first aspect, in one implementation, after synchronously exporting the business metadata file, the graph model file, and the graph data file of the target graph from the graph database, the method further includes:
[0011] Perform CRC (Cyclic Redundancy Check) encryption on the target graph’s business metadata file, graph model file, and graph data file respectively;
[0012] The encrypted business metadata files, graph model files and graph data files are compressed separately.
[0013] In combination with the first aspect, in one implementation, exporting the incremental snapshot of graph data of the target graph at the current backup time point from the graph database includes:
[0014] At the current backup time point, read the graph data change record of the target graph from the graph database;
[0015] Based on the graph data change record of the target graph, an incremental snapshot of the table and an incremental snapshot of the index corresponding to the target graph are generated respectively;
[0016] Based on the incremental snapshot of the table and the incremental snapshot of the index corresponding to the target graph, an incremental snapshot of graph data of the target graph at the current backup time point is generated.
[0017] In a second aspect, an embodiment of the present application provides a method for recovering a graph in a graph database, the method comprising:
[0018] Determine whether the data level of the target graph is lower than the preset data level;
[0019] If so, the graph database is controlled to load the business metadata file, graph model file, and graph data file of the target graph to restore the target graph;
[0020] If not, the graph database is controlled to load the target graph's business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph; the target time is the time corresponding to the historical state to which the target graph needs to be restored;
[0021] Among them, the business metadata file, graph model file, graph data file, full snapshot of graph data and incremental snapshot of graph data of the target graph are backed up using any of the above-mentioned graph backup methods in the graph database.
[0022] In conjunction with the second aspect, in one implementation, when the business metadata file, the graph model file, and the graph data file of the target graph are CRC encrypted and compressed, it also includes:
[0023] Decompress the target graph's business metadata file, graph model file, and graph data file respectively;
[0024] Perform CRC check on the decompressed business metadata file, graph model file and graph data file respectively.
[0025] In conjunction with the second aspect, in one implementation, controlling the graph database to load the business metadata file, the graph model file, and the graph data file of the target graph to restore the target graph includes:
[0026] The control graph database loads the business metadata file of the target graph to generate the business data of the target graph;
[0027] The control graph database loads the graph model file of the target graph to generate the graph model of the target graph;
[0028] The control graph database loads the graph data file of the target graph and writes the graph data of the target graph into the graph database.
[0029] In conjunction with the second aspect, in one implementation, the control graph database loads the business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time of the target graph to restore the target graph, including:
[0030] The control graph database loads the business metadata file of the target graph to generate the business data of the target graph;
[0031] The control graph database loads the graph model file of the target graph to generate the graph model of the target graph;
[0032] All incremental snapshots of graph data up to the target time are loaded in chronological order to restore the target graph.
[0033] In conjunction with the second aspect, in one implementation, the loading of all graph data incremental snapshots up to the target time in chronological order includes:
[0034] Load the table snapshot and index incremental snapshot corresponding to the target graph up to the target time in chronological order.
[0035] In a third aspect, an embodiment of the present application provides a device for backing up a graph in a graph database, the device comprising:
[0036] A judgment module, used to judge whether the data level of the target graph is lower than a preset data level;
[0037] The export module is used to export the business metadata file of the target graph, the graph model file, the graph data file, the full snapshot of the graph data at the current moment, and the incremental snapshot of the graph data of the target graph at the current backup time point from the graph database;
[0038] The storage module is used to store the target graph's business metadata files, graph model files, graph data files, the full snapshot of the graph data at the current moment, and the incremental snapshot of the target graph's graph data at the current backup time point to the backup storage path.
[0039] In a fourth aspect, an embodiment of the present application provides a device for recovering a graph in a graph database, the device comprising:
[0040] A judgment module, used to judge whether the data level of the target graph is lower than a preset data level;
[0041] A small data loading module is used to control the graph database to load the business metadata file, graph model file and graph data file of the target graph to restore the target graph;
[0042] The big data loading module is used to control the graph database to load the target graph's business metadata files, graph model files, full snapshots of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph.
[0043] The beneficial effects brought by the technical solution provided by the embodiments of the present application include:
[0044] By judging whether the data level of the target graph is lower than the preset data level, different backup and recovery strategies are implemented for the graph. When the data level of the target graph is lower than the preset data level, that is, in the small data scenario, the target graph is backed up by synchronously exporting the business metadata file, graph model file, and graph data file of the target graph, and the graph database is controlled to load the business metadata file, graph model file, and graph data file of the target graph to restore the target graph. Compared with taking a snapshot of the entire graph data, the speed of backup and recovery of the target graph is improved. When the data level of the target graph is higher than the preset data level, that is, in the big data scenario, the target graph is backed up by exporting the corresponding incremental snapshot of the graph data when the backup time point is reached. When restoring the target graph, the target graph can be restored by controlling the graph database to load all incremental snapshots of the graph data up to the target time, which reduces the resource consumption of the graph database. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flow chart of a first embodiment of a method for backing up a graph in a graph database of the present application;
[0046] Figure 2 This is a flow chart of a second embodiment of a method for backing up a graph in a graph database of the present application;
[0047] Figure 3 This is a flow chart of a third embodiment of a method for backing up a graph in a graph database of the present application;
[0048] Figure 4 This is a flow chart of the first embodiment of the method for recovering a graph in the graph database of the present application;
[0049] Figure 5 This is a flow chart of a second embodiment of a method for recovering a graph in a graph database of the present application;
[0050] Figure 6 This is a flow chart of a third embodiment of a method for recovering a graph in a graph database of the present application;
[0051] Figure 7 This is a schematic diagram of the structure of the backup device in the diagram database of an embodiment of the present application;
[0052] Figure 8 This is a schematic diagram of the structure of the recovery device in the diagram database of the embodiment of the present application;
[0053] Fig. 9 This is a schematic diagram of the architecture of the backup and recovery system of the graph database in the embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0055] First, some technical terms in the present application are explained to facilitate those skilled in the art to understand the present application.
[0056] POC: refers to the verification process of a certain technology, solution or idea in the early stage of a project. This process aims to confirm its feasibility and effectiveness and provide a solid basis for the implementation of subsequent projects. Through POC, the project team can evaluate the maturity of the technology, the applicability of the solution and the potential value of the idea, thereby reducing project risks and improving the scientificity and accuracy of decision-making.
[0057] JanusGraph: JanusGraph is an open source and distributed graph database designed for storing and querying large-scale graph data. It supports multiple storage backends (such as Cassandra, HBase, etc.), indexing technologies (solr, Elasticsearch, etc.) and Gremlin query language, and is suitable for complex scenarios such as social network analysis, knowledge graphs and recommendation systems.
[0058] Point (node): represents an entity or instance, such as a person, enterprise, or account. In a graph database, a point is one of the basic units of data.
[0059] Edge: represents the relationship between nodes and connects nodes together. Edges can be directed or undirected, and are used to indicate the direction and nature of the association between nodes.
[0060] CRC: It is a channel coding technology that generates a short fixed-bit check code based on data such as network data packets or computer files. It is mainly used to detect or check errors that may occur after data transmission or storage. The principle is that when sending data, the original data is regarded as a polynomial, and a modulo-2 division operation is performed based on this polynomial and a predefined generating polynomial. The remainder of the operation is attached to the end of the original data as a check code. When receiving the data, the receiver also uses the same generating polynomial to perform a modulo-2 division operation on the received data, and compares the remainder obtained with the check code attached by the sender. If they are consistent, it is considered that there is no error in the data transmission process.
[0061] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0062] First, please refer to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the method for backing up a graph in a graph database of the present application. The method for backing up a graph in a graph database provided by the present embodiment includes the following steps:
[0063] Step S1: Determine whether the data level of the target graph is lower than the preset data level; if so, proceed to step S2; if not, proceed to step S3.
[0064] Step S2: synchronously export the business metadata file, graph model file and graph data file of the target graph from the graph database and store them in the backup storage path.
[0065] Step S3: Synchronously export the business metadata file, graph model file, and full snapshot of the graph data at the current moment of the target graph from the graph database, and store them in the backup storage path.
[0066] Step S4: starting from the current moment, every time a preset backup time point is reached, an incremental snapshot of the graph data of the target graph at the current backup time point is exported from the graph database and stored in the backup storage path.
[0067] When the data level of the target graph is lower than the preset data level, that is, in the small data scenario, this method backs up the target graph by synchronously exporting the business metadata file, graph model file, and graph data file of the target graph, which improves the speed of backing up the target graph compared to taking a snapshot of the entire graph data. In the big data scenario, the target graph is backed up by exporting the corresponding incremental snapshot of the graph data when the backup time point is reached, which reduces the resource consumption of the graph database.
[0068] In some embodiments, the preset data level in the above step S1 is set to graph data containing 10,000 nodes and 100,000 edges. This setting is used to distinguish between small data scenarios and big data scenarios, so that different backup and recovery strategies can be adopted according to the different data levels. When the data level of the target graph is lower than this preset value, the backup and recovery method suitable for small data scenarios is adopted; and when the data level exceeds this preset value, the backup and recovery strategy suitable for big data scenarios is adopted.
[0069] In some embodiments, after synchronously exporting the business metadata file, graph model file, and graph data file of the target graph from the graph database, the following steps are also included:
[0070] First, the business metadata file, graph model file and graph data file of the target graph are CRC encrypted respectively, and then the encrypted business metadata file, graph model file and graph data file are compressed respectively.
[0071] In some embodiments, in the above step S4, exporting the incremental snapshot of the graph data of the target graph at the current backup time point from the graph database includes the following steps:
[0072] S41: At the current backup time point, read the graph data change record of the target graph from the graph database.
[0073] S42: Based on the graph data change record of the target graph, an incremental snapshot of the table and an incremental snapshot of the index corresponding to the target graph are generated respectively.
[0074] S43: Generate an incremental snapshot of graph data of the target graph at the current backup time point based on the incremental snapshot of the table and the incremental snapshot of the index corresponding to the target graph.
[0075] In a more specific embodiment, please refer to Figure 2 , Figure 2 This is a flow chart of the second embodiment of the method for backing up a graph in a graph database of the present application. When the data level of the target graph is lower than the preset data level, the method for backing up a graph in a graph database provided by the present embodiment includes the following steps:
[0076] Step A01: initiate a request to back up the target map, and then simultaneously enter step A02, step A03 and step A04.
[0077] Step A02: Query the business database, obtain the MySQL business metadata file, and then proceed to step A05.
[0078] Step A03: Call the graph model query API (Application Programming Interface) of JanusGraph to obtain the model of the target graph, generate the JanusGraph graph model metadata file, and then enter step A05.
[0079] Step A04: Call the graph data query API of JanusGraph, traverse the graph data, generate the GraphSon graph data file, and then proceed to step A05.
[0080] Step A05: Store the MySQL business metadata file, JanusGraph graph model metadata file, and GraphSon graph data file in the specified HDFS path.
[0081] Step A06: Perform CRC encryption on the MySQL business metadata file, JanusGraph graph model metadata file, and GraphSon graph data file.
[0082] Step A07: Zip compress the encrypted MySQL business metadata file, JanusGraph graph model metadata file and GraphSon graph data file.
[0083] In a more specific embodiment, please refer to Figure 3 , Figure 3 This is a flow chart of the third embodiment of the method for backing up a graph in a graph database of the present application. When the data level of the target graph is higher than the preset data level, the method for backing up a graph in a graph database provided by the present embodiment includes the following steps:
[0084] Step B01: Initiate a request to back up the target graph.
[0085] Step B02: Determine whether the snapshot configuration of the underlying storage Hbase and Elasticsearch is enabled. If so, proceed to step B03, step B04 and step B05 at the same time; if not, end this process.
[0086] Step B03: Query the business library, obtain the MySQL business metadata file, call the JanusGraph graph model query API, obtain the model of the target graph, generate the JanusGraph graph model metadata file, and then proceed to step B06.
[0087] Step B04: At 0:00 every day, a snapshot operation is performed on the HBase table corresponding to the target graph to obtain an incremental snapshot of the HBase table corresponding to the target graph of the previous day, and then the process proceeds to step B06.
[0088] Step B05: At 0:00 every day, a snapshot operation is performed on the Elasticsearch index corresponding to the target graph to obtain an incremental snapshot of the Elasticsearch index corresponding to the target graph of the previous day, and then the process proceeds to step B06.
[0089] Step B06: Store the MySQL business metadata file, JanusGraph graph model metadata file, HBase table incremental snapshot, and Elasticsearch index incremental snapshot to the specified path of HDFS.
[0090] Second, please refer to Figure 4 , Figure 4 This is a flow chart of the first embodiment of the method for recovering a graph in a graph database of the present application. The method for recovering a graph in a graph database provided by this embodiment includes the following steps:
[0091] Step C1: Determine whether the data level of the target graph is lower than the preset data level. If so, proceed to step C2; if not, proceed to step C3.
[0092] Step C2: Control the graph database to load the business metadata file, graph model file and graph data file of the target graph to restore the target graph.
[0093] Step C3: Control the graph database to load the target graph's business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph. The target time is the time corresponding to the historical state to which the target graph needs to be restored.
[0094] In this embodiment, the business metadata file, graph model file, graph data file, full snapshot of graph data and incremental snapshot of graph data of the target graph are backed up using the backup method of the graph in the graph database in any of the above embodiments.
[0095] When the data level of the target graph is lower than the preset data level, that is, in a small data scenario, this method restores the target graph by controlling the graph database to load the business metadata file, graph model file and graph data file of the target graph, thereby improving the speed of target graph recovery compared to restoring the target graph through a graph data snapshot. When the data level of the target graph is higher than the preset data level, that is, in a big data scenario, this method restores the target graph by controlling the graph database to load all graph data incremental snapshots up to the target time, thereby reducing the resource consumption of the graph database.
[0096] In some embodiments, when the business metadata file, graph model file and graph data file of the target graph are CRC encrypted and compressed, the following steps are also included:
[0097] First, the business metadata file, graph model file and graph data file of the target graph are decompressed respectively, and then the decompressed business metadata file, graph model file and graph data file are subjected to CRC check respectively.
[0098] In some embodiments, in the above step C2, controlling the graph database to load the business metadata file, graph model file, and graph data file of the target graph to restore the target graph includes the following steps:
[0099] C21: Controls the graph database to load the business metadata file of the target graph and generates the business data of the target graph.
[0100] C22: Controls the graph database to load the graph model file of the target graph and generates the graph model of the target graph.
[0101] C23: Controls the graph database to load the graph data file of the target graph, and writes the graph data of the target graph into the graph database.
[0102] In some embodiments, in the above step C3, controlling the graph database to load the business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time of the target graph to restore the target graph includes the following steps:
[0103] C31: Controls the graph database to load the business metadata file of the target graph and generates the business data of the target graph.
[0104] C32: Controls the graph database to load the graph model file of the target graph and generates the graph model of the target graph.
[0105] C33: Load all incremental snapshots of graph data up to the target time in chronological order to restore the target graph.
[0106] In some embodiments, in the above step C33, all incremental snapshots of graph data up to the target time are loaded in chronological order, specifically:
[0107] Load the table snapshot and index incremental snapshot corresponding to the target graph up to the target time in chronological order.
[0108] In a more specific embodiment, please refer to Figure 5 , Figure 5 This is a flow chart of the second embodiment of the method for recovering a graph in a graph database of the present application. When the data level of the target graph is lower than the preset data level, the method for recovering a graph in a graph database provided by the present embodiment includes the following steps:
[0109] Step D01: Initiate a request to restore the target graph.
[0110] Step D02: Decompress the compressed files in the specified path of HDFS to obtain the MySQL business metadata file, JanusGraph graph model metadata file and GraphSon graph data file.
[0111] Step D03: Perform CRC check on the MySQL business metadata file, JanusGraph graph model metadata file and GraphSon graph data file respectively. If the check succeeds, proceed to step D04, step D05 and step D06 at the same time; if the check fails, end this process.
[0112] Step D04: Load the MySQL business metadata file and generate business data.
[0113] Step D05: Load the JanusGraph graph model metadata file and generate the JanusGraph graph model.
[0114] Step D06: Load the GraphSon graph data file and write the graph data.
[0115] In a more specific embodiment, please refer to Figure 6 , Figure 6 This is a flow chart of the third embodiment of the method for recovering a graph in a graph database of the present application. When the data level of the target graph is higher than the preset data level, the method for recovering a graph in a graph database provided by the present embodiment includes the following steps:
[0116] Step E01: Initiate a request to restore the target graph.
[0117] Step E02: Determine whether the snapshot configuration of the underlying storage HBase and Elasticsearch is enabled. If so, proceed to step E03; if not, end this process.
[0118] Step E03: Load the MySQL business metadata file and generate business data, load the JanusGraph graph model metadata file and generate the JanusGraph graph model, then enter step E04 and step E05 at the same time.
[0119] Step E04: Copy the HBase table snapshot to the specified snapshot directory, and then load the HBase table snapshot.
[0120] Step E05: Copy the Elasticsearch index snapshot to the specified snapshot directory, and then load the Elasticsearch index snapshot.
[0121] Third, please refer to Figure 7 , Figure 7The schematic diagram of the structure of the backup device of the graph database in the embodiment of the present application is as follows. The backup device of the graph database provided in the embodiment includes a judgment module, an export module and a storage module.
[0122] The judgment module is used to judge whether the data level of the target graph is lower than the preset data level.
[0123] The export module is used to export the business metadata file, graph model file, graph data file, full snapshot of graph data at the current moment, and incremental snapshot of graph data of the target graph at the current backup time point from the graph database.
[0124] The storage module is used to store the target graph's business metadata files, graph model files, graph data files, the full snapshot of the graph data at the current moment, and the incremental snapshot of the target graph's graph data at the current backup time point to the backup storage path.
[0125] Fourth, please refer to Figure 8 , Figure 8 The schematic diagram of the structure of the device for recovering a graph in a graph database according to an embodiment of the present application is as follows. The device for recovering a graph in a graph database according to the present embodiment includes a judgment module, a small data loading module and a large data loading module.
[0126] The judgment module is used to judge whether the data level of the target graph is lower than the preset data level.
[0127] The small data loading module is used to control the graph database to load the business metadata file, graph model file and graph data file of the target graph to restore the target graph.
[0128] The big data loading module is used to control the graph database to load the target graph's business metadata files, graph model files, full snapshots of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph.
[0129] In some embodiments, please refer to Fig. 9 , Fig. 9 This is a schematic diagram of the architecture of the backup and recovery system of the graph database in the embodiment of the present application. The backup device of the graph database and the recovery device of the graph database are both run on the system. The system includes a source data layer, a business layer, a graph engine layer, a graph database layer and a data backup layer.
[0130] The source data layer provides linking and querying functions for the data sources to be stored.
[0131] The business layer includes graph modeling, exporting, and restoring functions for business data. The model data, business metadata, and graph data contained in the graph can be exported and backed up. The graph model, business metadata, and graph data can also be restored based on the exported files and backed-up data files.
[0132] The graph engine layer provides the ability to add, delete, modify, and query JanusGraph graph data. You can add, delete, modify, and query JanusGraph graph data through native APIs, or you can operate through Gremlin statements.
[0133] The graph data layer is responsible for storing the graph data and graph model data in the database. HBase is used as the underlying graph data storage system, and Elasticsearch is used as the index.
[0134] The data backup layer is responsible for storing the exported or backed-up graph models, graph data, and business metadata sql files. The selected storage system is HDFS.
[0135] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0136] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.
[0137] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.
[0138] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.
[0139] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.
[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.
[0141] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for backing up a graph in a graph database, characterized in that: The method comprises: Determine whether the data level of the target graph is lower than the preset data level; If yes, the business metadata file, graph model file and graph data file of the target graph are synchronously exported from the graph database and stored in the backup storage path; If not, the business metadata file, graph model file and full snapshot of the graph data at the current moment of the target graph are synchronously exported from the graph database and stored in the backup storage path; starting from the current moment, every time a preset backup time point is reached, an incremental snapshot of the graph data of the target graph at the current backup time point is exported from the graph database and stored in the backup storage path.
2. The method for backing up a graph in a graph database according to claim 1, characterized in that: After synchronously exporting the target graph's business metadata file, graph model file, and graph data file from the graph database, it also includes: Perform CRC encryption on the target graph’s business metadata file, graph model file, and graph data file respectively; The encrypted business metadata files, graph model files and graph data files are compressed separately.
3. The method for backing up a graph in a graph database according to claim 1, characterized in that: The step of exporting the graph data incremental snapshot of the target graph at the current backup time point from the graph database includes: At the current backup time point, read the graph data change record of the target graph from the graph database; Based on the graph data change record of the target graph, respectively generate an incremental snapshot of the table and an incremental snapshot of the index corresponding to the target graph; Based on the incremental snapshot of the table and the incremental snapshot of the index corresponding to the target graph, an incremental snapshot of graph data of the target graph at the current backup time point is generated.
4. A method for recovering a graph in a graph database, characterized in that: The method comprises: Determine whether the data level of the target graph is lower than the preset data level; If so, the graph database is controlled to load the business metadata file, graph model file, and graph data file of the target graph to restore the target graph; If not, the graph database is controlled to load the target graph's business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph; the target time is the time corresponding to the historical state to which the target graph needs to be restored; Among them, the business metadata file, graph model file, graph data file, full snapshot of graph data and incremental snapshot of graph data of the target graph are backed up using the backup method of the graph in the graph database as described in any one of claims 1-3.
5. The method for recovering a graph in a graph database according to claim 4, characterized in that: When the target graph's business metadata file, graph model file, and graph data file are CRC encrypted and compressed, they also include: Decompress the target graph's business metadata file, graph model file, and graph data file respectively; Perform CRC check on the decompressed business metadata file, graph model file and graph data file respectively.
6. The method for recovering a graph in a graph database according to claim 4, characterized in that: Control the graph database to load the business metadata file, graph model file, and graph data file of the target graph to restore the target graph, including: The control graph database loads the business metadata file of the target graph to generate the business data of the target graph; The control graph database loads the graph model file of the target graph to generate the graph model of the target graph; The control graph database loads the graph data file of the target graph and writes the graph data of the target graph into the graph database.
7. The method for recovering a graph in a graph database according to claim 4, characterized in that: The control graph database loads the target graph's business metadata file, graph model file, full snapshot of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph, including: The control graph database loads the business metadata file of the target graph to generate the business data of the target graph; The control graph database loads the graph model file of the target graph to generate the graph model of the target graph; All incremental snapshots of graph data up to the target time are loaded in chronological order to restore the target graph.
8. The method for recovering a graph in a graph database according to claim 7, characterized in that: The method of sequentially loading all graph data incremental snapshots up to the target time in chronological order includes: Load the table snapshot and index incremental snapshot corresponding to the target graph up to the target time in chronological order.
9. A backup device for a graph in a graph database based on the method according to any one of claims 1 to 3, characterized in that: The device comprises: A judgment module, used to judge whether the data level of the target graph is lower than a preset data level; The export module is used to export the business metadata file of the target graph, the graph model file, the graph data file, the full snapshot of the graph data at the current moment, and the incremental snapshot of the graph data of the target graph at the current backup time point from the graph database; The storage module is used to store the target graph's business metadata files, graph model files, graph data files, the full snapshot of the graph data at the current moment, and the incremental snapshot of the target graph's graph data at the current backup time point to the backup storage path.
10. A device for recovering a graph in a graph database based on the method of claim 4, characterized in that: The device comprises: A judgment module, used to judge whether the data level of the target graph is lower than a preset data level; A small data loading module is used to control the graph database to load the business metadata file, graph model file and graph data file of the target graph to restore the target graph; The big data loading module is used to control the graph database to load the target graph's business metadata files, graph model files, full snapshots of graph data, and all incremental snapshots of graph data up to the target time to restore the target graph.