Continuous data protection method, apparatus, electronic device, and storage medium
By creating a replica image file and performing data initialization operations before the virtual machine starts, combined with backfilling for continuous data protection, the problem of time-consuming virtual machine initialization is solved, and the startup speed of the virtual machine is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG CHANMING INFORMATION TECH CO LTD
- Filing Date
- 2024-07-12
- Publication Date
- 2026-05-15
AI Technical Summary
Continuous data protection takes a significant amount of time to initialize before the virtual machine is enabled, which affects the operation of the virtualization environment.
Before the virtual machine starts, a temporary copy image file is created based on the disk image file. The copy image file is used as the disk medium for the virtual machine to perform data initialization operations. At the same time, continuous data protection is used to record the data. After initialization, the modified data is restored to the disk image file through backfilling.
It improves the startup speed of virtual machines, solves the problem of time-consuming initialization, and allows virtual machines to record data sources without pausing operation during the initial startup phase.
Smart Images

Figure CN118734294B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtual machine technology, and more specifically, to a method, apparatus, electronic device, and storage medium for continuous data protection. Background Technology
[0002] Continuous data protection is an efficient data backup and recovery strategy that records data modifications and metadata in real time, supports recovery to any historical point in time within seconds, and achieves near-zero data loss. It is especially suitable for cloud computing virtualization environments, such as virtual machines.
[0003] However, before the virtual machine is enabled, continuous data protection needs to be initialized to record the initial data of the data source to prevent data loss during recovery. However, this recording process requires pausing the writing of the data source, which is time-consuming for a large amount of initial data and affects the operation of the virtualization environment.
[0004] There is currently no effective technical solution to the above problems. Summary of the Invention
[0005] The purpose of this application is to provide a continuous data protection method, apparatus, electronic device, and storage medium to solve the problem of long initialization time in continuous data protection and improve the startup speed of virtual machines.
[0006] Firstly, this application provides a persistent data protection method applied in a virtual machine, the persistent data protection method comprising the following steps:
[0007] S1. Create a temporary copy image file based on the disk image file, and use the copy image file as the disk medium for the virtual machine;
[0008] S2. Start the virtual machine, perform data operations based on the replica image file and record them based on continuous data protection, and perform data initialization operations, including: recording the disk image file and the corresponding metadata into continuous data protection;
[0009] S3. After the data initialization operation is completed, the disk image file is switched to the disk medium of the virtual machine;
[0010] S4. Backfill the disk image file according to the backup file of the continuous data protection;
[0011] S5. Perform data operations based on the disk image file and record them based on continuous data protection.
[0012] The continuous data protection method of this application temporarily creates a copy image file based on the disk image file before the virtual machine starts, and uses the copy image file as the disk medium used by the virtual machine in the early stage. At the same time, data initialization operations are performed, so that the virtual machine does not need to stop running to record the data source in the early stage of startup. After the data initialization operation is completed, the disk image file is backfilled through the continuous data protection data recovery function, so that the disk image file can accurately obtain the modified data after the data initialization operation is completed. This allows the disk medium to be smoothly switched from the copy image file to the disk image file, which can greatly improve the startup speed of the virtual machine and effectively solve the problem of initialization time in continuous data protection.
[0013] The continuous data protection method further includes steps performed prior to step S2:
[0014] A1. Set the disk image file to read-only;
[0015] Step S3 includes:
[0016] S31. After the data initialization operation is completed, the disk image file is switched to the disk medium of the virtual machine, and the disk image file is restored to a readable and writable file.
[0017] To more effectively prevent disk image files from being contaminated during data initialization operations, the continuous data protection method of this application sets the disk image file as a read-only file before starting the virtual machine, thereby preventing the virtual machine or the real system from accidentally modifying the data content of the disk image file and causing the data initialization operation to fail.
[0018] The continuous data protection method further includes, in step S3:
[0019] S32. Delete the aforementioned copy image file.
[0020] To prevent excessive accumulation of replica image files from consuming system resources, the continuous data protection method of this application deletes the replica image files created during the startup of the virtual machine after setting the disk image file as the disk medium.
[0021] The continuous data protection method, wherein step S4 includes:
[0022] Based on the time node of the completion of the data initialization operation, the data operation of the replica image file will be performed before that time node, and the disk image file will be backfilled by retrieving the backup file of continuous data protection.
[0023] In the continuous data protection method described above, both the disk image file and the copy image file are QCOW2 files.
[0024] The continuous data protection method, wherein the step of temporarily creating a replica image file based on the disk image file includes:
[0025] Use the disk image file as the parent file to temporarily create an empty copy image file.
[0026] In the continuous data protection method described above, steps S4 and S5 are executed simultaneously.
[0027] Secondly, this application also provides a persistent data protection device for use in a virtual machine, the persistent data protection device comprising:
[0028] The replica creation module is used to temporarily create a replica image file based on the disk image file, and use the replica image file as the disk medium for the virtual machine;
[0029] An initialization module is used to start the virtual machine, perform data operations based on the replica image file and record data based on continuous data protection, and perform data initialization operations, including recording the disk image file and its corresponding metadata into continuous data protection.
[0030] The switching module is used to switch the disk image file to the disk medium of the virtual machine after the data initialization operation is completed;
[0031] The backfill module is used to backfill the disk image file based on the backup file of the continuous data protection.
[0032] The data protection module is used to perform data operations based on the disk image file and to record data based on continuous data protection.
[0033] The continuous data protection device of this application temporarily creates a copy image file based on the disk image file before the virtual machine starts, and uses the copy image file as the disk medium used by the virtual machine in the early stage. At the same time, data initialization operations are performed, so that the virtual machine does not need to pause to record the data source in the early stage of startup. After the data initialization operation is completed, the disk image file is backfilled through the continuous data protection data recovery function, so that the disk image file can accurately obtain the modified data after the data initialization operation is completed. This allows the disk medium to be smoothly switched from the copy image file to the disk image file, which can greatly improve the startup speed of the virtual machine and effectively solve the problem of initialization time in continuous data protection.
[0034] Thirdly, this application also provides an electronic device, including a processor and a memory, the memory storing computer-readable instructions that, when executed by the processor, perform the steps of the method provided in the first aspect above.
[0035] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the method provided in the first aspect above.
[0036] As can be seen from the above, this application provides a continuous data protection method, apparatus, electronic device, and storage medium. The continuous data protection method temporarily creates a copy image file based on the disk image file before the virtual machine starts, and uses the copy image file as the disk medium initially used by the virtual machine. Simultaneously, data initialization operations are performed, allowing the virtual machine to start without pausing to record data sources. After the data initialization operation is completed, the disk image file is backfilled using the continuous data protection data recovery function, enabling the disk image file to accurately obtain the modified data from the data initialization operation. This allows the disk medium to smoothly transition from the copy image file to the disk image file, significantly improving the virtual machine's startup speed and effectively solving the problem of time-consuming initialization in continuous data protection. Attached Figure Description
[0037] Figure 1 A flowchart illustrating the continuous data protection method provided in this application embodiment.
[0038] Figure 2 This is a schematic diagram of the structure of the continuous data protection device provided in the embodiments of this application.
[0039] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0040] Reference numerals: 201, Copy creation module; 202, Initialization module; 203, Switching module; 204, Backfilling module; 205, Data protection module; 301, Processor; 302, Memory; 303, Communication bus. Detailed Implementation
[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0042] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0043] Firstly, please refer to Figure 1 This application provides a persistent data protection method in some embodiments, applied in a virtual machine. The persistent data protection method includes the following steps:
[0044] S1. Create a temporary copy image file based on the disk image file, and use the copy image file as the disk medium for the virtual machine;
[0045] S2. Start the virtual machine, perform data operations based on the replica image file and record them based on continuous data protection, and perform data initialization operations, including: recording the disk image file and the corresponding metadata into continuous data protection;
[0046] S3. After the data initialization operation is completed, switch the disk image file to the virtual machine's disk media;
[0047] S4. Backfill the disk image file based on the backup file for continuous data protection;
[0048] S5. Perform data operations based on disk image files and record data based on continuous data protection.
[0049] Specifically, the continuous data protection method of this application embodiment is used to perform continuous data protection for virtual machines, and is particularly suitable for situations where the data source in the virtual machine already contains data before the virtual machine starts. In this application embodiment, the disk image file is the data source.
[0050] More specifically, in existing virtual machines, disk image files are generally used directly as the disk medium of the virtual machine. The continuous data protection method of this application adds a copy image file as the disk medium used in the early stage of virtual machine startup, so as to back up the data initially stored in the disk image file while taking into account the startup speed of the virtual machine.
[0051] More specifically, the copy image file is a temporarily created file with the same format as the disk image file. It is used to replace the disk image file as disk media during the initial startup of the virtual machine, so as to avoid data operations during the initial startup of the virtual machine from polluting the disk image file and affecting the backup of the disk image file. The copy image file needs to be created before the virtual machine is officially started. Therefore, step S1 can be a pre-operation that is executed before the virtual machine starts according to the virtual machine startup command, or it can be a closing operation that serves the next virtual machine startup after the virtual machine is shut down.
[0052] More specifically, the copy image file can be an image file that can automatically read relevant data from the disk image file according to the virtual machine's usage requirements, or it can be an image file that copies data from the disk image file. In this embodiment, the former is preferred, which can further save the startup time of the virtual machine.
[0053] More specifically, after the virtual machine starts, users can perform normal operations, which will generate data operations on the replica image file. These data operations are operations that modify the virtual machine storage medium. The data generated during this operation includes modified data and metadata. Modified data includes written data, and metadata includes one or more of timestamps, disk offsets, and sizes. Continuous data protection is used to record data operations, that is, to record modified data based on metadata (especially timestamps and disk offsets).
[0054] More specifically, after the virtual machine starts, step S2 also performs an initialization operation on the disk image file. This initialization operation is actually used to record the data in the data source into the continuous data protection, which is equivalent to backing up the data content in the disk image file. During this process, the data operations generated by the user's normal operations are all modifications to the copy image file. The modified data generated during the process is written to the copy image file and recorded in the continuous data protection without affecting the data content in the disk image file. This allows step S2 to successfully and completely record the original disk image file and its corresponding metadata into the continuous data protection. The metadata corresponding to the disk image file can be characteristic data about the disk image file, such as disk offset and size, and can also include a timestamp determined based on the virtual machine startup time, so that the continuous data protection can restore the disk image file to its original state in subsequent operations.
[0055] More specifically, in step S2, the user's normal operation and the data initialization operation are performed simultaneously and do not affect each other. That is, the data initialization operation will not affect the user's normal operation, so that the user can directly start the virtual machine to perform the operation.
[0056] More specifically, the completion of the data initialization operation means that the original disk image file and its corresponding metadata have been completely recorded in the continuous data protection. This means that the continuous data protection can restore the disk image file to its original state in subsequent operations. In this case, the disk image file can be switched back to the disk medium directly used by the virtual machine. However, considering that during the data initialization operation, the copy image file generates modified data that the disk image file does not have based on data operations, the continuous data protection method of this application uses step S4 to perform backfilling processing on the disk image file, so that the disk image file has the modified data added to the copy image file during the data initialization operation. The continuous data protection includes data recording function and data recovery function. The backfilling process actually uses the data recovery function of the continuous data protection to restore the modification records of the copy image file during the data initialization operation to the disk image file, so that the modified data of the disk image file and the copy image file are aligned.
[0057] More specifically, after the backfilling process for the disk image file is completed, the user can continue to perform normal operations, which will generate data operations performed on the disk image file; the continuous data protection in step S5 is also used to record data operations, the difference being that the data operations recorded are related to the disk image file.
[0058] It should be noted that the amount of modified data corresponding to the modification records of the replica image file during the data initialization operation is generally much smaller than the data content of the disk image file. Therefore, step S4 can complete the backfilling process instantly without affecting the user experience.
[0059] It should be noted that the backup file for continuous data protection is a file used to record the aforementioned modified data and metadata.
[0060] The continuous data protection method of this application embodiment temporarily creates a copy image file based on the disk image file before the virtual machine starts, and uses the copy image file as the disk medium used by the virtual machine in the early stage. At the same time, data initialization operation is performed, so that the virtual machine does not need to pause to record the data source in the early stage of startup. After the data initialization operation is completed, the disk image file is backfilled through the continuous data protection data recovery function, so that the disk image file can accurately obtain the modified data after the data initialization operation is completed. This allows the disk medium to be smoothly switched from the copy image file to the disk image file, which can greatly improve the startup speed of the virtual machine and effectively solve the problem of initialization time in continuous data protection.
[0061] In some preferred embodiments, the continuous data protection method further includes steps performed prior to step S2:
[0062] A1. Set the disk image file to read-only;
[0063] Step S3 includes:
[0064] S31. After the data initialization operation is completed, switch the disk image file to the virtual machine's disk medium and restore the disk image file to a readable and writable file.
[0065] Specifically, in order to more effectively prevent the disk image file from being contaminated during data initialization operations, the continuous data protection method of this application sets the disk image file as a read-only file before starting the virtual machine, so as to prevent the virtual machine or the real system from accidentally modifying the data content of the disk image file and causing the data initialization operation to fail.
[0066] It should be noted that step A1 is executed before step S2. It can be executed between step S1 and step S2, or before step S1, or simultaneously with step S1. In this embodiment of the application, it is preferred to be executed between step S1 and step S2.
[0067] More specifically, after the data initialization operation is completed, step S31 requires restoring the read-only disk image file to a read-write file before subsequent backfilling and data operations can be performed.
[0068] In some preferred embodiments, step S3 further includes:
[0069] S32. Delete the copy mirror file.
[0070] Specifically, based on the foregoing, the continuous data protection method of this application creates a temporary copy image file before each virtual machine startup. In order to avoid excessive accumulation of copy image files and thus occupying system resources, the continuous data protection method of this application deletes the copy image file created for each virtual machine startup after setting the disk image file as the disk medium.
[0071] In some preferred embodiments, step S4 includes:
[0072] S41. Based on the time node of the completion of the data initialization operation, for the data operation of the replica image file, the disk image file is backfilled by retrieving the backup file of continuous data protection.
[0073] Specifically, the continuous data protection method of this application marks the corresponding time node when the initialization operation is completed, and obtains time node P1. This allows step S41 to actually restore the data of the disk image file based on time node P1 using the modification records of the copy image file during the data initialization operation in the backup file of continuous data protection, so as to achieve the effect of backfilling. The backfilling process actually directly uses the data recovery function of continuous data protection after switching disk media, without the need for additional special backfilling logic, and can make full use of the functional characteristics of continuous data protection.
[0074] In some preferred embodiments, both the disk image file and the copy image file are QCOW2 files.
[0075] Specifically, in the embodiments of this application, the virtual machine is preferably QEMU (Quick Emulator), so the corresponding disk image file and copy image file are preferably QCOW2 (QEMU copy on write version 2) format image files. QCOW2 file is a copy-on-write file that can be used to copy data to achieve continuous data protection.
[0076] In some preferred embodiments, the step of temporarily creating a copy image file based on a disk image file includes:
[0077] Use the disk image file as the parent file to temporarily create an empty copy image file.
[0078] Specifically, based on the foregoing, the copy image file is preferably an image file that can automatically read relevant data from the disk image file according to the virtual machine's usage requirements. Therefore, the continuous data protection method of this application embodiment designs the copy image file as an empty image file, so that the copy image file can be created instantly without affecting the virtual machine startup time. After the virtual machine starts, the copy image file can read the corresponding data from the read-only parent file (disk image file) according to the virtual machine's usage requirements to enable the normal use of the virtual machine. New modified data generated by the virtual machine will be written to the copy image file.
[0079] In some preferred embodiments, steps S4 and S5 are performed simultaneously.
[0080] Specifically, the continuous data protection method of this application embodiment can further optimize the user experience by synchronously executing steps S4 and S5 after switching the disk image file to disk media, that is, concurrently performing backfilling processing and data operations on the disk image file without waiting for the backfilling processing to complete.
[0081] More specifically, since the data content in the disk image file has already undergone data initialization, the backfilled data will not pollute or affect the recorded data. The operating system or running programs are generally temporarily stored in RAM (Random Access Memory). The disk image file undergoing backfilling will not affect the user's normal operation. The modified data corresponding to the data operations generated by the user's normal operation can be directly written into the disk image file undergoing backfilling.
[0082] Secondly, please refer to Figure 2 Some embodiments of this application also provide a persistent data protection device applied in a virtual machine. The persistent data protection device includes:
[0083] The replica creation module 201 is used to temporarily create a replica image file based on the disk image file, and use the replica image file as the disk medium of the virtual machine.
[0084] The initialization module 202 is used to start the virtual machine, perform data operations based on the replica image file and record data based on continuous data protection, and perform data initialization operations, including recording the disk image file and corresponding metadata into continuous data protection.
[0085] The switching module 203 is used to switch the disk image file to the virtual machine's disk medium after the data initialization operation is completed;
[0086] Backfill module 204 is used to backfill disk image files based on backup files for continuous data protection;
[0087] Data protection module 205 is used to perform data operations based on disk image files and to record data based on continuous data protection.
[0088] The continuous data protection device of this application embodiment temporarily creates a copy image file based on the disk image file before the virtual machine starts, and uses the copy image file as the disk medium used by the virtual machine in the early stage. At the same time, data initialization operation is performed, so that the virtual machine does not need to pause to record the data source in the early stage of startup. After the data initialization operation is completed, the disk image file is backfilled through the continuous data protection data recovery function, so that the disk image file can accurately obtain the modified data after the data initialization operation is completed. This allows the disk medium to be smoothly switched from the copy image file to the disk image file, which can greatly improve the startup speed of the virtual machine and effectively solve the problem of initialization time in continuous data protection.
[0089] In some preferred embodiments, the continuous data protection device of this application is used to perform the continuous data protection method provided in the first aspect above.
[0090] Thirdly, please refer to Figure 3 Some embodiments of this application also provide a schematic diagram of the structure of an electronic device. This application provides an electronic device including: a processor 301 and a memory 302. The processor 301 and the memory 302 are interconnected and communicate with each other through a communication bus 303 and / or other forms of connection mechanism (not shown). The memory 302 stores computer-readable instructions that can be executed by the processor 301. When the electronic device is running, the processor 301 executes the computer-readable instructions to execute the method in any optional implementation of the above embodiments.
[0091] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program performs the method in any optional implementation of the above embodiments. The computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0092] In summary, the embodiments of this application provide a continuous data protection method, apparatus, electronic device, and storage medium. The continuous data protection method temporarily creates a copy image file based on a disk image file before the virtual machine starts, and uses this copy image file as the disk medium initially used by the virtual machine. Simultaneously, data initialization operations are performed, allowing the virtual machine to start without pausing to record data sources. After the data initialization operation is completed, the disk image file is backfilled using the continuous data protection data recovery function, enabling the disk image file to accurately obtain the modified data from the data initialization operation. This allows the disk medium to smoothly transition from the copy image file to the disk image file, significantly improving the virtual machine's startup speed and effectively solving the initialization time problem inherent in continuous data protection.
[0093] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0094] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0095] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0096] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0097] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A continuous data protection method, applied in a virtual machine, characterized in that, The continuous data protection method includes the following steps: S1. Create a temporary copy image file based on the disk image file, and use the copy image file as the disk medium for the virtual machine; S2. Start the virtual machine, perform data operations based on the replica image file and record them based on continuous data protection, and perform data initialization operations, including: recording the disk image file and the corresponding metadata into continuous data protection; S3. After the data initialization operation is completed, the disk image file is switched to the disk medium of the virtual machine; S4. Backfill the disk image file according to the backup file of the continuous data protection; S5. Perform data operations based on the disk image file and record them based on continuous data protection. Steps S4 and S5 are executed synchronously. Modified data corresponding to data operations generated by normal user operations are directly written into the disk image file that is undergoing backfilling. The continuous data protection method further includes steps performed prior to step S2: A1. Set the disk image file to read-only; Step S3 includes: S31. After the data initialization operation is completed, the disk image file is switched to the disk medium of the virtual machine, and the disk image file is restored to a readable and writable file; The steps for temporarily creating a copy image file based on a disk image file include: Use the disk image file as the parent file to temporarily create an empty copy image file.
2. The continuous data protection method according to claim 1, characterized in that, Step S3 also includes: S32. Delete the aforementioned copy image file.
3. The continuous data protection method according to claim 1, characterized in that, Step S4 includes: Based on the time node of the completion of the data initialization operation, the data operation of the replica image file will be performed before that time node, and the disk image file will be backfilled by retrieving the backup file of continuous data protection.
4. The continuous data protection method according to claim 1, characterized in that, Both the disk image file and the copy image file are QCOW2 files.
5. A continuous data protection device, applied in a virtual machine, characterized in that, The continuous data protection device is used to perform the continuous data protection method as described in any one of claims 1-4, including: The replica creation module is used to temporarily create a replica image file based on the disk image file, and use the replica image file as the disk medium for the virtual machine; An initialization module is used to start the virtual machine, perform data operations based on the replica image file and record data based on continuous data protection, and perform data initialization operations, including recording the disk image file and its corresponding metadata into continuous data protection. The switching module is used to switch the disk image file to the disk medium of the virtual machine after the data initialization operation is completed; The backfill module is used to backfill the disk image file based on the backup file of the continuous data protection. The data protection module is used to perform data operations based on the disk image file and record data based on continuous data protection, wherein the steps of backfilling the disk image file according to the backup file of the continuous data protection and the steps of performing data operations based on the disk image file and recording data based on continuous data protection are executed synchronously.
6. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-readable instructions that, when executed by the processor, perform the steps of the method as described in any one of claims 1-4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it performs the steps of the method as described in any one of claims 1-4.