Application consistency backup method and device based on Kubernetes, computer equipment, readable storage medium and program product

By locking resources in the Kubernetes API for snapshot backup and flashing application-layer memory data to disk, the problem of data loss and incomplete backup in Kubernetes is solved, and application-consistent backup is achieved, and backup is improved. Flexibility and adaptability.

CN119201549AInactive Publication Date: 2024-12-27GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411313851.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Kubernetes does not provide application data persistence and backup functions, resulting in the risk of data loss when using Kubernetes. Traditional technology can only back up data volumes but not application status, resulting in incomplete backups.

Method used

By obtaining resource group information in the Kubernetes API, locking the resource to be backed up as read-only for snapshot backup, and saving the backup resource information to the target memory, restoring it to the read-write state, increasing the flashing of the application-level memory data to disk and Shortly freeze the write operation to achieve application-consistent backup.

Benefits of technology

Overcome the problem of incomplete backup in traditional technology, implement application-consistent backup, and improve the flexibility and adaptability of backups, reduce learning costs, and be able to deviate from complex Kubernetes configurations and implement more complex logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201549A_ABST
    Figure CN119201549A_ABST
Patent Text Reader

Abstract

The invention relates to an application consistency backup method and device based on Kubernetes, computer equipment, a storage medium and a computer program product, and relates to the technical field of computers. By adopting the method, the application consistency backup can be realized, and the problem of incomplete backup in the traditional technology is solved. The method comprises the steps of obtaining a backup task created by a user in response to a backup creation request sent by the user; traversing resource positioning information in the Kubernetes API according to the backup task to obtain resource group information corresponding to the backup task; determining resource information to be backed up according to the resource group information; locking the to-be-backed-up resource information to be in a read-only state, and performing snapshot backup on the to-be-backed-up resource information to obtain backup resource information; and storing the backup resource information, and recovering the to-be-backed-up resource information to a read-write state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a Kubernetes-based application consistency backup method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the development of computer technology, an open source container orchestration platform Kubernetes (K8s) has emerged, which can manage the deployment and expansion of containerized applications in a cluster. However, Kubernetes itself does not provide application data persistence and backup functions, so how to avoid data loss becomes a problem when using Kubernetes.

[0003] In traditional technology, VolumeSnapshot API is usually used to snapshot the data of PV (Persistent Volume) and then save it to backup storage. However, VolumeSnapshot can only back up data volumes, but cannot back up other information such as application status, resulting in incomplete backup in this backup method. Summary of the invention

[0004] Based on this, it is necessary to provide a Kubernetes-based application consistency backup method, device, computer equipment, computer-readable storage medium and computer program product to address the above technical problems.

[0005] In a first aspect, the present application provides an application consistency backup method based on Kubernetes, comprising:

[0006] In response to a backup creation request sent by a user, obtaining a backup task created by the user;

[0007] Traversing the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task;

[0008] Determine resource information to be backed up according to the resource group information;

[0009] The resource information to be backed up is locked in a read-only state, and a snapshot backup is performed on the resource information to be backed up to obtain backup resource information;

[0010] The backup resource information is saved, and the resource information to be backed up is restored to a read-write state.

[0011] In one embodiment, locking the resource information to be backed up as a read-only state includes:

[0012] In response to the received first SQL command, the resource information to be backed up is locked in a read-only state so as to freeze the writing of the resource information to be backed up;

[0013] The restoring the resource information to be backed up to a read-write state includes:

[0014] In response to the received second SQL command, the resource information to be backed up is restored to a read-write state to unfreeze the resource information to be backed up.

[0015] In one embodiment, the storing the backup resource information includes:

[0016] Create a temporary pod and identify the type of the backup resource information; if the backup resource information is identified as a PVC (Persistent Volume Claim) type, obtain a target PVC according to the backup resource information, and mount the target PVC to the temporary pod; start the temporary pod that mounts the target PVC to save the backup resource information to the target storage.

[0017] In one embodiment, the method further comprises:

[0018] In the case where the backup resource information fails to be saved, the save operation on the backup resource information is re-executed until the backup resource information is successfully saved; in the case where the backup resource information is successfully saved, the temporary pod and the target PVC are deleted.

[0019] In one embodiment, the method further comprises:

[0020] In response to the recovery creation request sent by the user, a recovery task created by the user is obtained; corresponding data backup information is read from the target storage according to the recovery task; resources are sorted for the data backup information, and a resource creation request is sent to the Kubernetes API according to the resource sorting, and resource information to be restored corresponding to the resource creation request is copied from the target storage to the Kubernetes API.

[0021] In one embodiment, determining the resource information to be backed up according to the resource group information includes:

[0022] Determine resource list information according to the resource group information; obtain information identifier of the resource information to be backed up, and determine the resource information to be backed up in the resource list information according to the information identifier.

[0023] In a second aspect, the present application also provides an application consistency backup device based on Kubernetes, including:

[0024] A task acquisition module, used to respond to a backup creation request sent by a user and acquire a backup task created by the user;

[0025] An information acquisition module, used to traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task;

[0026] An information determination module, used to determine the resource information to be backed up according to the resource group information;

[0027] An information backup module, used to lock the resource information to be backed up into a read-only state, perform a snapshot backup of the resource information to be backed up, and obtain backup resource information;

[0028] The information saving module is used to save the backup resource information and restore the resource information to be backed up to a read-write state.

[0029] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0030] In response to a backup creation request sent by a user, a backup task created by the user is obtained; resource location information in the Kubernetes API is traversed according to the backup task to obtain resource group information corresponding to the backup task; resource information to be backed up is determined according to the resource group information; the resource information to be backed up is locked in a read-only state, a snapshot backup of the resource information to be backed up is performed to obtain backup resource information; the backup resource information is saved, and the resource information to be backed up is restored to a read-write state.

[0031] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0032] In response to a backup creation request sent by a user, a backup task created by the user is obtained; resource location information in the Kubernetes API is traversed according to the backup task to obtain resource group information corresponding to the backup task; resource information to be backed up is determined according to the resource group information; the resource information to be backed up is locked in a read-only state, a snapshot backup of the resource information to be backed up is performed to obtain backup resource information; the backup resource information is saved, and the resource information to be backed up is restored to a read-write state.

[0033] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0034] In response to a backup creation request sent by a user, a backup task created by the user is obtained; resource location information in the Kubernetes API is traversed according to the backup task to obtain resource group information corresponding to the backup task; resource information to be backed up is determined according to the resource group information; the resource information to be backed up is locked in a read-only state, a snapshot backup of the resource information to be backed up is performed to obtain backup resource information; the backup resource information is saved, and the resource information to be backed up is restored to a read-write state.

[0035] The above-mentioned Kubernetes-based application consistency backup method, device, computer equipment, computer-readable storage medium and computer program product obtain the backup task created by the user by responding to the backup creation request sent by the user; traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task; determine the resource information to be backed up according to the resource group information; after locking the resource information to be backed up as a read-only state, perform a snapshot backup of the resource information to be backed up to obtain the backup resource information; save the backup resource information, and restore the resource information to be backed up to a read-write state. On the basis of using the Kubernetes API to take a snapshot of the requested PVC, the present application also adds operations on the application, by flushing the data in the application layer memory to the disk, and temporarily freezing the write, and then taking a snapshot backup of the disk, the backup of the application consistency is realized and the problem of incomplete backup in traditional technology is overcome. In addition, compared with the method of using the application template method to perform application consistency, the present application is more flexible and adaptable, with a low learning cost, can be separated from the complex configuration of Kubernetes, and implement more complex logic. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0037] FIG1 is an application environment diagram of an application consistency backup method based on Kubernetes in one embodiment;

[0038] Figure 2 It is a flowchart of an application consistency backup method based on Kubernetes in one embodiment;

[0039] Figure 3 A schematic diagram of a process for saving backup resource information in one embodiment;

[0040] Figure 4 It is a flowchart of an application consistency backup method based on Kubernetes in a specific embodiment;

[0041] Figure 5 It is a structural block diagram of an application consistency backup device based on Kubernetes in one embodiment;

[0042] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0044] The Kubernetes-based application consistency backup method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal communicates with the server through the network. The data storage system can store the data that the server needs to process. The data storage system can be integrated on the server, or it can be placed on the cloud or other network servers.

[0045] Specifically, the Kubernetes-based application consistency backup method provided in the embodiment of the present application can be executed by a server.

[0046] Exemplarily, the server responds to a backup creation request sent by a user and obtains a backup task created by the user; the server traverses the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task; the server determines the resource information to be backed up according to the resource group information; the server locks the resource information to be backed up as a read-only state, performs a snapshot backup of the resource information to be backed up, and obtains the backup resource information; the server saves the backup resource information, and restores the resource information to be backed up to a read-write state.

[0047] In the application environment shown in FIG1 , the terminal may be, but is not limited to, various personal computers, notebook computers, smart phones, and tablet computers. The server may be implemented as an independent server or a server cluster consisting of multiple servers.

[0048] In one embodiment, Figure 2As shown, a Kubernetes-based application consistency backup method is provided, which is described by taking the method applied to the server in FIG1 as an example, and includes the following steps:

[0049] Step S201: In response to a backup creation request sent by a user, a backup task created by the user is obtained.

[0050] It should be noted that obtaining the backup task created by the user can be determined according to actual applications, and this embodiment does not impose any specific limitation.

[0051] Optionally, the backup task is obtained in the following manner: the server receives a backup task creation request sent by backupd in response to a backup creation request sent by the user; wherein the backup task creation request is determined by backupd according to the user's input request information.

[0052] Step S202: traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task.

[0053] Specifically, the server traverses the resource location information in the Kubernetes API according to the backup task, identifies and obtains the resource group information corresponding to the backup task.

[0054] Step S203: Determine resource information to be backed up according to the resource group information.

[0055] Specifically, the server determines resource list information according to the resource group information; obtains the information identifier of the resource information to be backed up, and determines the resource information to be backed up in the resource list information according to the information identifier.

[0056] For example, in the present application, the resource group information, the resource list information and the specific resource information to be backed up may be traversed hierarchically in a circular manner.

[0057] Step S204: lock the resource information to be backed up into a read-only state, perform a snapshot backup on the resource information to be backed up, and obtain the backup resource information.

[0058] Among them, snapshot backup is a data protection method that backs up data by creating a snapshot of a data volume at a certain point in time.

[0059] To further explain, the snapshot saves data in read-only mode to ensure the integrity and consistency of the snapshot data. Users cannot modify the data in the snapshot, thereby avoiding accidental or malicious changes to the snapshot content.

[0060] Specifically, in response to the received first SQL command, the server locks the resource information to be backed up into a read-only state to freeze the writing of the resource information to be backed up, and then performs a snapshot backup on the resource information to be backed up to obtain the backup resource information.

[0061] Step S205, save the backup resource information, and restore the resource information to be backed up to a read-write state.

[0062] Specifically, the server creates a temporary pod and identifies the type of the backup resource information; if the backup resource information is identified as a PVC type, the target PVC is obtained according to the backup resource information, and the target PVC is mounted to the temporary pod; the temporary pod with the target PVC mounted is started to save the backup resource information to the target storage, and the resource information to be backed up is restored to a read-write state.

[0063] The target storage may be an external storage, such as a hard disk drive (HDD), a solid state drive (SSD), or a network attached storage (NAS).

[0064] In the above-mentioned Kubernetes-based application consistency backup method, by responding to the backup creation request sent by the user, the backup task created by the user is obtained; according to the backup task, the resource location information in the Kubernetes API is traversed to obtain the resource group information corresponding to the backup task; according to the resource group information, the resource information to be backed up is determined; after the resource information to be backed up is locked as a read-only state, a snapshot backup is performed on the resource information to be backed up to obtain the backup resource information; the backup resource information is saved, and the resource information to be backed up is restored to a read-write state. On the basis of using the Kubernetes API to take a snapshot of the requested PVC, this application also adds operations on the application, by flushing the data in the application layer memory to the disk, freezing the write for a short time, and then taking a snapshot backup of the disk, an application consistency backup is achieved and the problem of incomplete backup in traditional technology is overcome. In addition, compared with the method of using the application template method to perform application consistency, the flexibility and adaptability of this application are stronger, it can be separated from the complex configuration of Kubernetes, and more complex logic can be implemented.

[0065] In one embodiment, in the above step S204, locking the resource information to be backed up as a read-only state specifically includes the following steps:

[0066] In response to the received first SQL command, the resource information to be backed up is locked in a read-only state to freeze the writing of the resource information to be backed up;

[0067] In the above step S205, restoring the resource information to be backed up to a read-write state specifically includes the following steps:

[0068] In response to the received second SQL command, the resource information to be backed up is restored to a read-write state to unfreeze the resource information to be backed up.

[0069] The first SQL command may be a command for executing an SQL statement in MySQL. The command will lock all tables in a read-only state to ensure data consistency. The command is usually used before a backup operation to prevent data from changing during the backup process.

[0070] The second SQL command may also be a command for executing an SQL statement in MySQL, which is used to release the previously locked table and restore it to a normal read-write state. This is very important after completing a specific backup operation so that other operations can proceed normally.

[0071] Specifically, in response to the received first SQL command, the server locks the resource information to be backed up into a read-only state so that the resource information to be backed up is frozen from being written, and then performs a snapshot backup of the resource information to be backed up to obtain the backup resource information; then the backup resource information is saved, and in response to the received second SQL command, the resource information to be backed up is restored to a read-write state so that the resource information to be backed up is unfrozen.

[0072] In this embodiment, based on the persistent volume snapshot, additional operations are performed on the application, such as MySQL, to flush the data in the application layer memory to the disk, freeze the write for a short time, and then snapshot the disk to achieve a complete backup with application consistency.

[0073] In one embodiment, if Figure 3 As shown, in the above step S205, the backup resource information is saved, which specifically includes the following steps:

[0074] Step S301: create a temporary pod and identify the type of backup resource information.

[0075] Step S302: If the backup resource information is identified as a PVC type, a target PVC is obtained according to the backup resource information, and the target PVC is mounted to a temporary pod.

[0076] Step S303: Start the temporary pod that mounts the target PVC to save the backup resource information to the target storage.

[0077] Among them, pod is the basic execution unit in Kubernetes. It is a collection of one or more containers with shared storage, network and operating environment.

[0078] Among them, PVC refers to the object of storage resource requested by the user, which describes the storage requirements, such as size and access mode.

[0079] Specifically, the server creates a temporary pod and identifies the type of the backup resource information; if the backup resource information is identified as a PVC type, the target PVC is obtained according to the backup resource information, and the target PVC is mounted to the temporary pod; the temporary pod with the target PVC mounted is started to save the backup resource information to the target storage. Otherwise, the server copies the backup resource information to the resource information database for storage.

[0080] The method in this embodiment has strong flexibility and adaptability, can be separated from the complex configuration of Kubernetes, and implement more complex logic.

[0081] In one embodiment, after the backup resource information is saved, the method of the present application further includes the following steps:

[0082] If the backup resource information fails to be saved, re-execute the save operation on the backup resource information until the backup resource information is saved successfully; if the backup resource information is saved successfully, delete the temporary pod and the target PVC.

[0083] Specifically, when the server identifies that the backup resource information fails to be saved, it re-executes the save operation on the backup resource information until the backup resource information is successfully saved; when it identifies that the backup resource information is successfully saved, it sends a request to Kubernetes to delete the temporary pod and the target PVC.

[0084] In this embodiment, by deleting the temporary pod and the target PVC when the backup resource information is successfully saved, the cluster environment in Kubernetes is restored.

[0085] In one embodiment, the method of the present application further includes the following steps:

[0086] In response to the recovery creation request sent by the user, the recovery task created by the user is obtained; the corresponding data backup information is read from the target storage according to the recovery task; the data backup information is sorted by resources, and a resource creation request is sent to the Kubernetes API according to the resource sorting, and the resource information to be restored corresponding to the resource creation request is copied from the target storage to the Kubernetes API.

[0087] It should be noted that obtaining the recovery task created by the user is determined according to actual applications, and this embodiment does not impose any specific limitation.

[0088] Optionally, the recovery task is obtained in the following manner: receiving a recovery task creation request sent by backupd; wherein the recovery task creation request is determined by backupd according to user input request information.

[0089] Specifically, the server responds to the recovery creation request sent by the user and obtains the recovery task created by the user; reads the corresponding data backup information from the target storage according to the recovery task; sorts the data backup information by resources, and sends a resource creation request to the Kubernetes API according to the resource sorting, and copies the resource information to be restored corresponding to the resource creation request from the target storage to the Kubernetes API.

[0090] It should be noted that recovery is basically the reverse process of backup, and recovery is performed in the order of resources. When the restored resources include PVC, after the resources are restored, the backup data volume in the target storage is restored to the PVC (a temporary pod needs to be started).

[0091] In one embodiment, in the above step S203, determining the resource information to be backed up according to the resource group information specifically includes the following steps:

[0092] Determine resource list information according to resource group information; obtain information identifier of resource information to be backed up, and determine resource information to be backed up in resource list information according to the information identifier.

[0093] Among them, information identification usually refers to specific marks or labels used to identify, classify or describe information. These identifications help in the management, retrieval and use of information. Common types include: metadata, tags and unique identifiers.

[0094] Specifically, the server determines the resource list information according to the resource group information; obtains the information identifier of the resource information to be backed up, and identifies and obtains the resource information to be backed up in the resource list information according to the information identifier.

[0095] In this embodiment, the resource group information, the resource list information and the specific resource information to be backed up are traversed in order in a circular manner, so that the resource information to be backed up can be quickly and accurately identified in the resource list information according to the information identifier.

[0096] In one embodiment, Figure 4 As shown, a method for application consistency backup based on Kubernetes in a specific embodiment is provided, which specifically includes the following steps:

[0097] Step S401: In response to a backup creation request sent by a user, a backup task created by the user is obtained.

[0098] Step S402, traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task; determine the resource list information according to the resource group information; obtain the information identifier of the resource information to be backed up, and determine the resource information to be backed up in the resource list information according to the information identifier.

[0099] Step S403, in response to the received first SQL command, the resource information to be backed up is locked in a read-only state to freeze the writing of the resource information to be backed up, and a snapshot backup is performed on the resource information to be backed up to obtain the backup resource information.

[0100] Step S404, create a temporary pod, and identify the type of backup resource information; if the backup resource information is identified as a PVC type, obtain the target PVC according to the backup resource information, and mount the target PVC to the temporary pod; start the temporary pod mounting the target PVC to save the backup resource information to the target storage, and in response to the received second SQL command, restore the resource information to be backed up to a read-write state to unfreeze the resource information to be backed up.

[0101] Step S405, in response to the recovery creation request sent by the user, obtain the recovery task created by the user; read the corresponding data backup information from the target storage according to the recovery task; sort the data backup information by resources, and send a resource creation request to the Kubernetes API according to the resource sorting, and copy the resource information to be restored corresponding to the resource creation request from the target storage to the Kubernetes API.

[0102] The beneficial effects brought by the above embodiments are as follows:

[0103] This application not only uses the Kubernetes API to take snapshots of PV, but also adds operations on the application. By flushing the data in the application layer memory to the disk, freezing the write for a short time, and then taking a snapshot backup of the disk, the backup of the application consistency is achieved and the problem of incomplete backup in traditional technology is overcome. In addition, compared with the method of using the application template method to perform application consistency, this application is more flexible and adaptable. The caller only needs to learn about the shell, which has a low learning cost, can be separated from the complex configuration of Kubernetes, and implement more complex logic (such as json information).

[0104] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0105] Based on the same inventive concept, the embodiment of the present application also provides a Kubernetes-based application consistency backup device for implementing the above-mentioned Kubernetes-based application consistency backup method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in the one or more Kubernetes-based application consistency backup device embodiments provided below can refer to the above limitations on the Kubernetes-based application consistency backup method, which will not be repeated here.

[0106] In an exemplary embodiment, Figure 5 As shown, a Kubernetes-based application consistency backup device is provided, including:

[0107] The task acquisition module 501 is used to respond to the backup creation request sent by the user and acquire the backup task created by the user;

[0108] An information acquisition module 502 is used to traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task;

[0109] An information determination module 503, configured to determine resource information to be backed up according to the resource group information;

[0110] The information backup module 504 is used to lock the resource information to be backed up into a read-only state, perform a snapshot backup of the resource information to be backed up, and obtain backup resource information;

[0111] The information saving module 505 is used to save the backup resource information and restore the resource information to be backed up to a read-write state.

[0112] In one embodiment, the information backup module 504 is further used to lock the resource information to be backed up into a read-only state in response to the received first SQL command so that the resource information to be backed up is frozen for writing; the information saving module 505 is further used to restore the resource information to be backed up to a read-write state in response to the received second SQL command so that the resource information to be backed up is unfrozen.

[0113] In one embodiment, the information saving module 505 is further used to create a temporary pod and identify the type of the backup resource information; if the backup resource information is identified as a PVC type, a target PVC is obtained according to the backup resource information, and the target PVC is mounted to the temporary pod; the temporary pod on which the target PVC is mounted is started to save the backup resource information to a target storage device.

[0114] In one embodiment, the Kubernetes-based application consistency backup device also includes an environment recovery module, which is used to re-execute the save operation of the backup resource information when the backup resource information fails to be saved until the backup resource information is successfully saved; when the backup resource information is successfully saved, delete the temporary pod and the target PVC.

[0115] In one embodiment, the Kubernetes-based application consistency backup device also includes a data recovery module, which is used to respond to the recovery creation request sent by the user, obtain the recovery task created by the user; read the corresponding data backup information from the target storage according to the recovery task; sort the data backup information by resources, and send a resource creation request to the Kubernetes API according to the resource sorting, and copy the resource information to be restored corresponding to the resource creation request from the target storage to the Kubernetes API.

[0116] In one embodiment, the information determination module 503 is further used to determine resource list information according to the resource group information; obtain the information identifier of the resource information to be backed up, and determine the resource information to be backed up in the resource list information according to the information identifier.

[0117] Each module in the above-mentioned Kubernetes-based application consistency backup device can be implemented in whole or in part by software, hardware, and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.

[0118] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store backup resource information. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for application consistency backup based on Kubernetes is implemented.

[0119] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0120] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0121] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0122] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0123] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0124] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0125] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0126] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A Kubernetes-based application consistency backup method, characterized in that: The method comprises: In response to a backup creation request sent by a user, obtaining a backup task created by the user; Traversing the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task; Determine resource information to be backed up according to the resource group information; The resource information to be backed up is locked in a read-only state, and a snapshot backup is performed on the resource information to be backed up to obtain backup resource information; The backup resource information is saved, and the resource information to be backed up is restored to a read-write state.

2. The method according to claim 1, characterized in that: The step of locking the resource information to be backed up into a read-only state includes: In response to the received first SQL command, the resource information to be backed up is locked in a read-only state so as to freeze the writing of the resource information to be backed up; The restoring the resource information to be backed up to a read-write state includes: In response to the received second SQL command, the resource information to be backed up is restored to a read-write state to unfreeze the resource information to be backed up.

3. The method according to claim 1, characterized in that The storing of the backup resource information includes: Creating a temporary pod and identifying the type of the backup resource information; If the backup resource information is identified as a PVC type, a target PVC is obtained according to the backup resource information, and the target PVC is mounted to the temporary pod; A temporary pod mounted with the target PVC is started to save the backup resource information into the target storage.

4. The method according to claim 3, characterized in that: The method further comprises: In the case where the backup resource information fails to be saved, re-execute the saving operation of the backup resource information until the backup resource information is successfully saved; When the backup resource information is saved successfully, the temporary pod and the target PVC are deleted.

5. The method according to claim 1, characterized in that The method further comprises: In response to the recovery creation request sent by the user, obtaining the recovery task created by the user; Reading corresponding data backup information from the target storage according to the recovery task; The data backup information is sorted by resources, and a create resource request is sent to the Kubernetes API according to the resource sorting, and the to-be-restored resource information corresponding to the create resource request is copied from the target storage to the Kubernetes API.

6. The method according to any one of claims 1 to 5, characterized in that: The step of determining the resource information to be backed up according to the resource group information includes: Determine resource list information according to the resource group information; The information identifier of the resource information to be backed up is obtained, and the resource information to be backed up is determined in the resource list information according to the information identifier.

7. An application consistency backup device based on Kubernetes, characterized in that: The device comprises: A task acquisition module, used to respond to a backup creation request sent by a user and acquire a backup task created by the user; An information acquisition module, used to traverse the resource location information in the Kubernetes API according to the backup task to obtain the resource group information corresponding to the backup task; An information determination module, used to determine the resource information to be backed up according to the resource group information; An information backup module, used to lock the resource information to be backed up into a read-only state, perform a snapshot backup of the resource information to be backed up, and obtain backup resource information; The information saving module is used to save the backup resource information and restore the resource information to be backed up to a read-write state.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Continuous on-line transferring data backup method of virtual machine and device thereof

    CN101609419A

  • Method and device for backup of data in database as well as game system

    CN105740104A

  • Automatic backup method based on LVM snapshot in cloud native environment

    CN113391952A

  • Backup method and device of application resources, electronic equipment and storage medium

    CN114328029A

  • Data processing method and system based on Kubernetes and medium

    CN115048240A