Data backup and data recovery method, device, equipment and medium
Through local backup strategies and sideCar monitoring technology, the problem of long data recovery time for container applications is solved, and an efficient data recovery process is achieved.
Patent Information
- Application Number
- CN202210587033.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-05-27
AI Technical Summary
The data recovery time of container applications is prolonged, mainly due to the long time it takes to copy data across devices due to reliance on third-party storage media.
Adopt local backup strategies, including immediate backup and scheduled backup, create scheduled backup execution resources through the apiserver interface, and use the sideCar method to monitor the container application for data recovery when the third-party storage volume resources are unavailable, update the third-party storage volume resources and mount the data backup directory into the container application.
This reduces the recovery time of container applications, avoids unnecessary cross-device data copying, and improves data recovery efficiency.
Smart Images

Figure CN114968666B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data backup technology, and in particular to a data backup and data recovery method, device, equipment and medium. Background Art
[0002] Container applications refer to applications built and deployed using container technology, such as Docker containers. Container applications are widely used in daily development, operations, maintenance, and testing. With the rapid development of container applications, they are now widely used in finance, telecommunications, electronics, government affairs, and other fields, resulting in a massive increase in the amount of data required to be stored by container applications. Currently, a large number of container applications are deployed based on containerization, with Kubernetes becoming the de facto standard for container application orchestration. Backing up container application data on Kubernetes generally relies on third-party storage media, such as backup appliances or object storage. Furthermore, after backing up to a remote appliance or object storage, restoring the container application often involves the time-consuming process of copying data across devices. This time consumption prolongs the recovery time of the container application.
[0003] In view of the above problems, finding how to shorten the recovery time of container applications is a problem that those skilled in the art are trying their best to solve. Summary of the Invention
[0004] The purpose of this application is to provide a data backup and data recovery method, apparatus, device and medium for reducing the recovery time of container applications.
[0005] To solve the above technical problems, this application provides a data backup and data recovery method, which is applied to container applications, including:
[0006] Get the data to be backed up;
[0007] Determine the backup strategy for the data to be backed up, which includes immediate backup and scheduled backup;
[0008] Back up the data to be backed up locally according to the backup strategy;
[0009] When the third-party storage volume resources mounted by the container application are unavailable, update the third-party storage volume resources and implement a recovery strategy for the data in the container application.
[0010] Preferably, locally backing up the data to be backed up according to the backup strategy includes:
[0011] Copy the data to be backed up to the data backup directory of the container application.
[0012] Preferably, when the backup strategy is scheduled backup, before copying the data to be backed up to the data backup directory of the container application, it also includes:
[0013] Call the apiserver interface;
[0014] Create scheduled backup execution resources through the apiserver interface;
[0015] Obtain and update scheduled backup execution resources in real time;
[0016] Back up the data to be backed up according to the scheduled backup execution resources.
[0017] Preferably, when the third-party storage volume resource mounted by the container application is unavailable, before updating the third-party storage volume resource, the method further includes:
[0018] Start the monitoring container application through sideCar;
[0019] Perform continuous read and write operations on third-party storage volume resources by monitoring container applications.
[0020] Preferably, updating the third-party storage volume resource includes:
[0021] Mount the data backup directory into the container application.
[0022] Preferably, mounting the data backup directory into the container application includes:
[0023] Get the local backup path of the data to be backed up;
[0024] Modify the usage of third-party storage volume resources in the local path;
[0025] Mount the data backup directory into the container application according to the modified usage method of the third-party storage volume resource.
[0026] Preferably, after executing the recovery strategy for the data in the container application, the method further includes:
[0027] Use the UI to copy the data backup directory mapped to the local path and remount it to the new third-party storage volume resource.
[0028] To solve the above technical problems, the present application further provides a data backup and data recovery device, which is applied to the above data backup and data recovery method and includes:
[0029] An acquisition module is used to obtain data to be backed up;
[0030] A determination module is used to determine a backup strategy for the data to be backed up, including immediate backup and scheduled backup;
[0031] The backup module is configured to locally backup the data to be backed up according to a backup strategy.
[0032] The updating and restoring module is configured to update the third-party storage volume resource and perform a restoring strategy on the data in the container application when the third-party storage volume resource mounted by the container application is unavailable.
[0033] In the apparatus, the following modules are further included:
[0034] The calling module is configured to call an apiserver interface.
[0035] The creating module is configured to create a timing backup execution resource through the apiserver interface.
[0036] The real-time obtaining module is configured to obtain and update the timing backup execution resource in real time.
[0037] The backup module is configured to backup the data to be backed up according to the timing backup execution resource.
[0038] Before updating the third-party storage volume resource when the third-party storage volume resource mounted by the container application is unavailable, the following steps are further included:
[0039] The starting module is configured to start a container application through a sideCar mode.
[0040] The continuous reading and writing module is configured to continuously read and write the third-party storage volume resource through the container application.
[0041] The updating of the third-party storage volume resource includes:
[0042] The first mounting module is configured to mount a data backup directory to the container application.
[0043] The mounting of the data backup directory to the container application includes:
[0044] The path obtaining module is configured to obtain a backup local path of the data to be backed up.
[0045] The modifying module is configured to modify a use mode of the third-party storage volume resource in the local path.
[0046] The second mounting module is configured to mount the data backup directory to the container application according to the modified use mode of the third-party storage volume resource.
[0047] After performing the restoring strategy on the data in the container application, the following steps are further included:
[0048] The second copying module is configured to copy and remount the data backup directory mapped by the local path into a new third-party storage volume resource through a UI.
[0049] To solve the above technical problems, the present application also provides a data backup and data recovery device, including:
[0050] memory for storing computer programs;
[0051] The processor is used to direct the computer program to implement the steps of the data backup and data recovery method.
[0052] To solve the above technical problems, the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements all the steps of the above-mentioned data backup and data recovery methods.
[0053] The present application provides a data backup and data recovery method, which is applied to container applications and includes: obtaining the data to be backed up; determining a backup strategy for the data to be backed up, which includes immediate backup and scheduled backup; locally backing up the data to be backed up according to the backup strategy; and when the third-party storage volume resource mounted by the container application is unavailable, updating the third-party storage volume resource and executing the recovery strategy for the data in the container application. Since the original method of backing up data on the third-party storage device is changed to local backup, backing up the data in the container application does not require copying data across devices, which results in unnecessary time consumption, thereby reducing the recovery time of the container application.
[0054] This application also provides a data backup and data recovery device, equipment and medium, with the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0056] Figure 1 A flow chart of a data backup and data recovery method provided in an embodiment of the present application;
[0057] Figure 2 A flowchart of another data backup and data recovery method provided in an embodiment of the present application;
[0058] Figure 3 A structural diagram of a data backup and data recovery device provided in an embodiment of the present application;
[0059] Figure 4 A structural diagram of a data backup and data recovery device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.
[0061] The core of the present application is to provide a data backup and data recovery method, device, equipment and medium, which can reduce the recovery time of container applications.
[0062] In order for those skilled in the art to better understand the present application, the present application will be further described in detail in combination with the drawings and specific embodiments.
[0063] Containers define a set of standardized systems from construction to execution, change the traditional virtualization technology, and deeply affect the cloud computing field. The container technology represented by Docker increasingly deeply affects cloud computing and also changes our daily development, operation and testing. Compared with virtual machines, containers are lightweight, fast to start and low in overhead, and based on this, the business packaging and micro-service mode are more suitable for large-scale cluster management and flexible distributed system building in many scenarios. Container applications refer to applications built and deployed using container technology represented by Docker. Docker refers to a container engine for container resource lifecycle management. Kubernetes is an open source container orchestration engine, and its main function is to automate the deployment of container applications and manage the lifecycle of container applications, also known as k8. When a large number of applications are deployed based on k8s, based on the demand for application data persistence, container applications will mount third-party shared storage such as ceph and nfs through PVC. When the third-party storage volume corresponding to the PVC mounted by the application fails or the third-party storage itself fails, the application mounted with this shared storage will fail due to the inability to read and write persistent data, thereby failing to provide services to the outside. PVC can be understood as a resource object in the Kubernetes container orchestration engine, which is an abstract resource object of a storage volume. At present, a large number of applications are deployed based on containers, and Kubernetes has become a de facto container application orchestration standard. At present, various commercial versions of container cloud platforms are basically packaged based on Kubernetes and Docker. At present, various platforms basically provide transparent transmission and packaging of corresponding functions. At present, the backup of container application data on Kubernetes generally relies on third-party storage media, such as backup all-in-one machines or object storage. And the recovery of the application after backup to the remote all-in-one machine or object storage often exists data cross-device copying time-consuming, which greatly delays the application recovery time.
[0064] Figure 1 A flowchart of a data backup and data recovery method provided in an embodiment of the present application.
[0065] like Figure 1 As shown, the data backup and data recovery method is applied to container applications and includes:
[0066] S10: Obtain the data to be backed up.
[0067] In this embodiment, the data to be backed up is generally in digital form, but it is not excluded that it can also be in text form. When the data to be backed up is in digital form, it can be a 2-bit, 4-bit, 8-bit or 16-bit data string. It should be noted that the data to be backed up is by no means limited to 2-bit, 4-bit, 8-bit and 16-bit data strings, and can also be a data string with more or fewer bits. When the data to be backed up is 2 bits, it can be expressed as "01"; when the data to be backed up is 4 bits, it can be expressed as "1001"; when the data to be backed up is 8 bits, it can be expressed as "11010101"; when the data to be backed up is 16 bits, it can be expressed as "1101010101111101". It should be noted that the above embodiment is only one of many embodiments and does not limit the number of bits of the data to be backed up and its representation.
[0068] S11: Determine a backup strategy for the data to be backed up.
[0069] Backup strategies include immediate backup and scheduled backup. Immediate backup involves performing a backup the next moment the data to be backed up is received; scheduled backup involves setting a set timer, with the backup only taking place when the set timer is reached. It is understood that the timer is pre-set, and the user can determine the length of the timer based on the specific implementation scenario. The timing method can be either positive or negative. For example, when the timer is set to 60 seconds, the timer can be counted down from 60 seconds to 0 seconds (countdown) or from 0 seconds to 60 seconds (positive). It should be noted that due to different functions, the timer can be set to different unit levels. For example, to avoid missing part of the data to be backed up, the timer can be set to milliseconds or microseconds. Similarly, to avoid excessive backup resource consumption, the timer can be set to seconds, minutes, hours, or even a day or a week. In this embodiment, the length of the timer, the timer unit, and the timing method are not limited and can be determined based on the specific implementation scenario. Furthermore, the timer can be displayed on an LED display or a time display composed of light-emitting diodes.
[0070] S12: Back up the data to be backed up locally according to the backup policy.
[0071] As described above, there are two backup strategies: immediate backup and scheduled backup. Immediate backup performs a backup the next moment the data to be backed up is received; scheduled backup performs a backup at a set time. It should be noted that if you select immediate backup as the backup strategy, you cannot select scheduled backup during the same backup cycle. Similarly, if you select scheduled backup as the backup strategy, you cannot select immediate backup during the same backup cycle. Immediate and scheduled backup are incompatible; only one backup strategy will be executed.
[0072] The container application backup policy is stored as a K8S custom resource, and the data is stored in the ETCD database. The key configuration items of the backup policy resources are as follows: ReleaseName: application name, BackupPolicy: backup policy, Cron: scheduled backup Cron expression, PvcName: storage volume name, MountPath: storage volume mount path.
[0073] The scheduled backup strategy calls the k8s apiserver interface to create a custom resource (Custom Resource). The resource YAML sample is as follows:
[0074]
[0075]
[0076] Traverse according to CronBack, find the node where the container storage volume is mounted, and modify the resource status of the custom resource to the node name.
[0077] S13: When the third-party storage volume resource mounted by the container application is unavailable, the third-party storage volume resource is updated and a recovery strategy is executed for the data in the container application.
[0078] When a third-party storage volume resource is unavailable, it indicates that the third-party storage volume resource has failed or some operation instructions cannot be used. Therefore, the third-party storage volume resource needs to be updated. The updated third-party storage volume resource will become available. When the third-party storage volume resource is available, the recovery policy is executed for the data in the container application.
[0079] The present application provides a data backup and data recovery method, which is applied to container applications and includes: obtaining the data to be backed up; determining a backup strategy for the data to be backed up, which includes immediate backup and scheduled backup; locally backing up the data to be backed up according to the backup strategy; and when the third-party storage volume resource mounted by the container application is unavailable, updating the third-party storage volume resource and executing the recovery strategy for the data in the container application. Since the original method of backing up data on the third-party storage device is changed to local backup, backing up the data in the container application does not require copying data across devices, which results in unnecessary time consumption, thereby reducing the recovery time of the container application.
[0080] Based on the above embodiment, as a more preferred embodiment, locally backing up the data to be backed up according to the backup policy includes:
[0081] Copy the data to be backed up to the data backup directory of the container application.
[0082] In this embodiment, the copy mentioned can be understood as migration, which involves migrating the data to be backed up to the container application's data backup directory. The container application's data backup directory can contain a variety of information, including data source, data storage path, data name, data usage, and so on. There are no restrictions on the type of information contained in the data backup directory, and the types of information contained in the data backup directory can be increased or decreased based on the specific implementation scenario.
[0083] Figure 2 This is another data backup and data recovery method flow chart provided by the embodiment of the present application. Based on the above embodiment, as a better embodiment, Figure 2 As shown, when the backup policy is scheduled backup, before copying the data to be backed up to the data backup directory of the container application, it also includes:
[0084] S20: Call the apiserver interface.
[0085] During the data backup process, multiple interfaces are used, as these interfaces support the custom creation of scheduled backup execution resources. The apiserver interface has the following functions: it provides a REST API interface for cluster management (including authentication and authorization, data verification, and cluster status changes); it serves as a hub for data interaction and communication between other modules; it serves as an entry point for resource quota control; and it has a comprehensive cluster security mechanism. Therefore, for user convenience and ease of adjusting backup-related data, the apiserver interface is chosen here. It should be noted that when the data to be backed up is received by this interface in digital form, it can be a 2-digit, 4-digit, 8-digit, or 16-digit data string. It should be noted that the data to be backed up is by no means limited to 2-digit, 4-digit, 8-digit, and 16-digit data strings, but can also be data strings with more or fewer digits. When the data to be backed up is 2 bits, it can be expressed as "01"; when the data to be backed up is 4 bits, it can be expressed as "1001"; when the data to be backed up is 8 bits, it can be expressed as "11010101"; when the data to be backed up is 16 bits, it can be expressed as "1101010101111101". It should be noted that the above embodiment is only one of many embodiments and does not limit the number of bits of the data to be backed up and its expression form.
[0086] S21: Create scheduled backup execution resources through the apiserver interface.
[0087] S22: Obtain and update scheduled backup execution resources in real time.
[0088] Since the scheduled backup execution resource may change during the data backup process, it is necessary to obtain the latest scheduled backup execution resource to facilitate data backup and avoid using an unupdated scheduled backup execution resource to back up the data to be backed up.
[0089] S23: Backing up the data to be backed up according to the scheduled backup execution resource.
[0090] Based on the above embodiment, as a more preferred embodiment, when the third-party storage volume resource mounted by the container application is unavailable, before updating the third-party storage volume resource, the method further includes:
[0091] S24: Start the monitoring container application through the sideCar method;
[0092] Dividing the functions of an application into separate processes is the sideCar pattern. When sideCar is used in software architecture, the sideCar application is connected to the parent application and extends or enhances its functions. SideCar is used for loose coupling with the main application. An example of a sideCar application scenario: suppose there are 6 microservices communicating with each other to jointly determine the cost of a package. Each microservice requires monitoring, logging, configuration, circuit breakers and other functions, which are implemented in each microservice using third-party libraries. The above scenario is only for the convenience of understanding and does not limit the technical solution of this application. The sideCar approach has the following advantages: by abstracting the common infrastructure related to the function to a different layer to reduce the complexity of the microservice code; because the application no longer needs to write the same third-party component configuration files and code, thereby reducing the complexity of the code in the microservice architecture; and reducing the coupling between the application and the underlying platform. Therefore, in this embodiment, the sideCar approach is used to start the listening container application.
[0093] S25: Perform continuous read and write operations on third-party storage volume resources by monitoring container applications.
[0094] The continuous read and write operations mentioned in this embodiment can be understood as the container application monitoring the third-party storage volume resource in real time, and cyclically executing operations such as small file creation, content writing, reading, and deletion on the third-party storage volume resource. If these operations can be cyclically executed on the third-party storage volume resource, it indicates that the third-party storage volume resource is available and the operation of executing the recovery policy on the data in the container application can be executed; if these operations cannot be cyclically executed on the third-party storage volume resource, it indicates that the third-party storage volume resource is unavailable and the operation of executing the recovery policy on the data in the container application cannot be executed.
[0095] Based on the above embodiment, as a more preferred embodiment, updating the third-party storage volume resource includes:
[0096] Mount the data backup directory into the container application.
[0097] At this time, since the third-party storage volume resources have been updated, the data backup directory needs to be mounted to the container application corresponding to the updated third-party storage volume resources to facilitate subsequent data backup or data recovery operations.
[0098] Based on the above embodiment, as a more preferred embodiment, mounting the data backup directory into the container application includes:
[0099] Get the local backup path of the data to be backed up;
[0100] Modify the usage of third-party storage volume resources in the local path;
[0101] Mount the data backup directory into the container application according to the modified usage method of the third-party storage volume resource.
[0102] The local backup method and principles for backing up data are as follows: Use cp to copy the PVC mounted on the container application to a fixed directory on the physical machine where the container group resides. The container application data backup directory is named / var / backdata / PODNAME / PVCNAME. Furthermore, after executing the recovery strategy for the container application data, the following steps are also performed:
[0103] S26: Use the UI to copy the data backup directory mapped to the local path and remount it to the new third-party storage volume resource.
[0104] When using Docker, we often need to utilize the Docker container environment but don't want to transfer code to the container. In these cases, we need Docker to mount a directory on the host machine into the container. Once inside the container application, the directory is mapped to the container application. To modify a file, simply add the test_modify command to the program. This command also supports real-time updates after modifications.
[0105] An example is as follows:
[0106]
[0107] In the above embodiments, the data backup and data recovery methods are described in detail. This application also provides corresponding embodiments of the data backup and data recovery apparatus. It should be noted that this application describes the embodiments of the apparatus from two perspectives: one is based on the functional module perspective, and the other is based on the hardware perspective.
[0108] Figure 3 This is a structural diagram of a data backup and data recovery device provided in an embodiment of the present application.
[0109] like Figure 3 As shown, the present application also provides a data backup and data recovery device, including:
[0110] An acquisition module 30 is used to acquire data to be backed up;
[0111] Determining module 31, used to determine the backup strategy of the data to be backed up, the backup strategy includes immediate backup and scheduled backup;
[0112] The backup module 32 is used to locally back up the data to be backed up according to the backup strategy;
[0113] The update and recovery module 33 is used to update the third-party storage volume resources and execute a recovery strategy for the data in the container application when the third-party storage volume resources mounted by the container application are unavailable.
[0114] In addition, this application also provides the following modules:
[0115] Backing up the data to be backed up locally according to the backup strategy includes:
[0116] The first copy module is used to copy the data to be backed up to the data backup directory of the container application.
[0117] When the backup policy is scheduled backup, before copying the data to be backed up to the data backup directory of the container application, the following steps are also included:
[0118] Call module, used to call the apiserver interface;
[0119] Create a module to create scheduled backup execution resources through the API server interface;
[0120] Real-time acquisition module, used to obtain and update scheduled backup execution resources in real time;
[0121] The backup execution module is used to back up the data to be backed up according to the scheduled backup execution resources.
[0122] When the third-party storage volume resources mounted by the container application are unavailable, before updating the third-party storage volume resources, the following steps are also included:
[0123] The startup module is used to start the monitoring container application through the sideCar method;
[0124] The continuous read and write module is used to perform continuous read and write operations on third-party storage volume resources by monitoring container applications.
[0125] Updating third-party storage volume resources includes:
[0126] The first mounting module is used to mount the data backup directory into the container application.
[0127] Mounting the data backup directory into the container application includes:
[0128] The path acquisition module is used to obtain the backup local path of the data to be backed up;
[0129] The modification module is used to modify the usage of third-party storage volume resources in the local path;
[0130] The second mounting module is used to mount the data backup directory into the container application according to the modified usage method of the third-party storage volume resource.
[0131] After executing the recovery strategy for the data in the container application, it also includes:
[0132] The second copy module is used to copy the data backup directory mapped by the local path through the UI and remount it to a new third-party storage volume resource.
[0133] The present application provides a data backup and data recovery method, which is applied to container applications and includes: obtaining the data to be backed up; determining a backup strategy for the data to be backed up, which includes immediate backup and scheduled backup; locally backing up the data to be backed up according to the backup strategy; and when the third-party storage volume resource mounted by the container application is unavailable, updating the third-party storage volume resource and executing the recovery strategy for the data in the container application. Since the original method of backing up data on the third-party storage device is changed to local backup, backing up the data in the container application does not require copying data across devices, which results in unnecessary time consumption, thereby reducing the recovery time of the container application.
[0134] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, and they will not be repeated here.
[0135] Figure 4 A data backup and data recovery device structure diagram provided in an embodiment of the present application is as follows: Figure 4 As shown, data backup and data recovery equipment includes:
[0136] Memory 40, for storing computer programs;
[0137] The processor 41 is configured to implement the steps of the data backup and data recovery method mentioned in the above embodiment when executing a computer program.
[0138] The data backup and data recovery devices provided in this embodiment may include but are not limited to smart phones, tablet computers, laptop computers, or desktop computers.
[0139] Among them, the processor 41 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 41 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 41 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 41 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 41 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0140] The memory 40 may include one or more computer-readable storage media, which may be non-transitory. The memory 40 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 40 is at least used to store the following computer program, wherein, after the computer program is loaded and executed by the processor 41, it can implement the relevant steps of the data backup and data recovery method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 40 may also include an operating system and data, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system may include Windows, Unix, Linux, etc. The data may include but is not limited to data backup and data recovery methods, etc.
[0141] In some embodiments, the data backup and data recovery device may further include a display screen, an input and output interface, a communication interface, a power supply, and a communication bus.
[0142] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the data backup and data recovery device, and may include more or fewer components than shown in the figure.
[0143] The data backup and data recovery device provided in the embodiment of the present application includes a memory 40 and a processor 41. The processor 41 can implement a data backup and data recovery method when executing a program stored in the memory 40. A data backup and data recovery method provided in the present application is applied to a container application, including: obtaining the data to be backed up; determining the backup strategy for the data to be backed up, the backup strategy including immediate backup and scheduled backup; locally backing up the data to be backed up according to the backup strategy; when the third-party storage volume resource mounted by the container application is unavailable, updating the third-party storage volume resource, and executing the recovery strategy for the data in the container application. Since the original way of backing up data by the third-party storage device is changed to local backup, the data in the container application does not need to be copied across devices, thereby generating unnecessary time consumption, thereby reducing the recovery time of the container application.
[0144] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiment.
[0145] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium and executes all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory), ROM, random access memory (Random Access Memory, RAM), disk or optical disk, and other media that can store program code.
[0146] The above is a detailed introduction to a data backup and data recovery method, device, equipment and medium provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0147] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
Claims
1. A data backup and data recovery method, characterized in that: Applicable to container applications, including: Get the data to be backed up; Determine a backup strategy for the data to be backed up, wherein the backup strategy includes immediate backup and scheduled backup; The data to be backed up is locally backed up according to the backup strategy; wherein, the backup strategy is stored in the form of K8S custom resources, and the data is stored in the ETCD database; the key resource configuration items of the backup strategy include application name, backup strategy, scheduled backup, expression, storage volume name, and storage volume mount path; When the third-party storage volume resource mounted by the container application is unavailable, updating the third-party storage volume resource and executing a recovery strategy for the data in the container application; The locally backing up the data to be backed up according to the backup strategy includes: Copying the data to be backed up to the data backup directory of the container application; When the backup strategy is the scheduled backup, before copying the data to be backed up to the data backup directory of the container application, the method further includes: Call the apiserver interface; Create scheduled backup execution resources through the apiserver interface; Acquire and update the scheduled backup execution resources in real time; Backing up the data to be backed up according to the scheduled backup execution resource; Before updating the third-party storage volume resource when the third-party storage volume resource mounted by the container application is unavailable, the method further includes: Start the monitoring container application through sideCar; Performing continuous read and write operations on the third-party storage volume resources through the monitoring container application; Updating the third-party storage volume resource includes: Mount the data backup directory into the container application; Mounting the data backup directory into the container application includes: Obtaining a backup local path for the data to be backed up; Modify the usage mode of the third-party storage volume resource in the backup local path; Mounting the data backup directory into the container application according to the modified usage mode of the third-party storage volume resource; After executing the recovery strategy on the data in the container application, the method further includes: The data backup directory mapped by the local path is copied through the UI and remounted to a new third-party storage volume resource.
2. A data backup and data recovery device, characterized in that: The data backup and data recovery method according to claim 1 includes: An acquisition module is used to obtain data to be backed up; A determination module, configured to determine a backup strategy for the data to be backed up, wherein the backup strategy includes immediate backup and scheduled backup; A backup module is used to locally back up the data to be backed up according to the backup strategy; wherein the backup strategy is stored in the form of K8S custom resources, and the data is stored in the ETCD database; the key resource configuration items of the backup strategy include application name, backup strategy, scheduled backup, expression, storage volume name, and storage volume mount path; An update and recovery module, configured to update the third-party storage volume resource when the third-party storage volume resource mounted by the container application is unavailable, and to execute a recovery strategy for the data in the container application; The backup module is configured to copy the data to be backed up to the data backup directory of the container application; The device is further configured to call an apiserver interface; create a scheduled backup execution resource through the apiserver interface; obtain and update the scheduled backup execution resource in real time; and back up the data to be backed up according to the scheduled backup execution resource; The device is further configured to start a monitoring container application in a sideCar manner; and perform continuous read and write operations on the third-party storage volume resources through the monitoring container application; The update and restore module is used to mount the data backup directory into the container application; The device is configured to obtain a backup local path for the data to be backed up; modify a usage mode of the third-party storage volume resource in the backup local path; and mount the data backup directory into the container application according to the modified usage mode of the third-party storage volume resource; The device is further configured to copy the data backup directory mapped by the local path through the UI and re-mount the copy to a new third-party storage volume resource.
3. A data backup and data recovery device, characterized in that: include: Memory for storing computer programs; A processor is configured to implement the steps of the data backup and data recovery method according to claim 1 when executing the computer program.
4. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data backup and data recovery method according to claim 1 are implemented.
Citation Information
Patent Citations
Container deployment method and device
CN111506391A