Virtual machine backup method and device, computer equipment and readable storage medium

By identifying the snapshot type of the virtualization software and dynamically selecting the backup strategy, combined with the merging mechanism to generate backup files, the compatibility problem of traditional virtual machine backup methods is solved, and cross-version backup consistency and stability are achieved.

CN120994460AActive Publication Date: 2025-11-21GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202510949948.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-11-21
Estimated Expiration
2045-07-10

AI Technical Summary

Technical Problem

Traditional virtual machine backup methods rely on a single snapshot mechanism, resulting in poor compatibility and difficulty in unified management across heterogeneous multi-version environments.

Method used

By identifying the snapshot type of the virtualization software, the system dynamically selects between external and internal snapshot methods and generates backup files using a merging mechanism, adapting to different virtualization software versions.

Benefits of technology

It improves the compatibility and stability of virtual machine backups, reduces backup chain risks, enhances data reliability and system adaptability, and expands the availability of lower versions of QEMU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994460A_ABST
    Figure CN120994460A_ABST
Patent Text Reader

Abstract

The invention relates to a virtual machine backup method and device, computer equipment and a readable storage medium. The method comprises the following steps: acquiring a snapshot type of virtualization software; copying a target copy file matched with the snapshot type to a backup server according to the snapshot type so as to generate a backup file in the backup server; wherein under the condition that the snapshot type is an external snapshot, the target copy file is determined based on an original disk file of the virtual machine or a disk file in a read-only state; under the condition that the snapshot type is an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine. By adopting the method, the compatibility of the backup function of the virtual machine can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of virtual machines, and particularly relates to a virtual machine backup method and device, a computer device and a readable storage medium. BACKGROUND

[0002] In a cloud computing environment, a virtual machine (VM) as an important means of resource abstraction and isolation carries a large amount of computing and storage tasks, which makes the reliability and security of cloud virtual machine data a research focus of the academic and industrial circles.

[0003] A traditional virtual machine backup method relies on a single snapshot mechanism, which leads to the problem of poor compatibility of the traditional backup method. SUMMARY

[0004] Therefore, it is necessary to provide a virtual machine backup method, device, computer device and readable storage medium capable of improving the compatibility of virtual machine backup.

[0005] In a first aspect, in one example, the present application provides a virtual machine backup method, which comprises the following steps.

[0006] Obtaining a snapshot type of virtualization software;

[0007] According to the snapshot type, copying a target copy file matching the snapshot type to a backup server to generate a backup file in the backup server;

[0008] In the case of the snapshot type being an external snapshot, the target copy file is determined based on an original disk file of the virtual machine or a disk file in a read-only state; in the case of the snapshot type being an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine.

[0009] In one of the embodiments, the backup file comprises a basic backup file; according to the snapshot type, copying the target copy file matching the snapshot type to the backup server to generate the backup file in the backup server comprises the following steps.

[0010] If the snapshot type is an external snapshot and it is determined that the basic backup file does not exist in the current backup server, determining a first disk file of the virtual machine as the target copy file; the first disk file is an original disk file configured as a read-only disk of the virtual machine;

[0011] Copying the target copy file to the backup server to generate the basic backup file in the backup server.

[0012] In one of the embodiments, the backup file further comprises an incremental backup file; the method further comprises the following steps.

[0013] if the snapshot type is an external snapshot and it is determined that the base backup file exists in the current backup server, creating a third disk file dependent on the second disk file based on the second disk file currently serving as the active disk of the virtual machine;

[0014] converting the second disk file from an active state to a read-only state and configuring the third disk file as the new active disk of the virtual machine;

[0015] determining the second disk file as a target copy file and copying the target copy file to the backup server to generate an incremental backup file in the backup server.

[0016] In one embodiment, after copying the target copy file to the backup server, the method further comprises:

[0017] merging the second disk file in the virtual machine with the read-only disk file on which the second disk file depends to obtain a fourth disk file;

[0018] configuring the fourth disk file as a new read-only disk of the virtual machine and configuring the third disk file as an active disk of the virtual machine dependent on the fourth disk file.

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

[0020] in response to receiving a disk recovery instruction and the snapshot type being an external snapshot, obtaining a backup file from the backup server;

[0021] if the backup file only includes the base backup file, determining the base backup file as a base disk file;

[0022] if the backup file includes the base backup file and the incremental backup file, merging the base backup file and the incremental backup file to obtain a base disk file;

[0023] creating a new virtual machine based on the base disk file.

[0024] In one embodiment, according to the snapshot type, copying the target copy file matching the snapshot type to the backup server to generate a backup file in the backup server comprises:

[0025] if the snapshot type is an internal snapshot, instructing the current virtual machine disk file to generate an internal snapshot point;

[0026] determining the complete virtual machine disk file of the current virtual machine as a target copy file, copying the target copy file to the backup server, and rolling back the virtual machine disk file to the internal snapshot point.

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

[0028] In response to receiving the disk recovery instruction and the snapshot type being an internal snapshot, obtaining a backup file of a specified internal snapshot point from the backup server;

[0029] Based on the backup file, a new virtual machine is created.

[0030] In a second aspect, in one example, the present application provides a virtual machine disk backup and restoration device, the device comprising:

[0031] A snapshot type obtaining module is configured to obtain a snapshot type of virtualization software.

[0032] A backup module is configured to copy a target copy file matching the snapshot type to a backup server according to the snapshot type, so as to generate a backup file in the backup server.

[0033] In the case of the snapshot type being an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine.

[0034] In a third aspect, in one example, the present application provides a computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.

[0035] In a fourth aspect, in one example, the present application provides a computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the steps in the above method embodiments.

[0036] The above virtual machine backup method, device, computer device and readable storage medium, by obtaining a snapshot type of virtualization software, and copying a target copy file matching the snapshot type to a backup server according to the snapshot type, so as to generate a backup file in the backup server; in this way, the present application can execute a corresponding type of backup strategy based on different snapshot types, thereby effectively improving the compatibility of the virtual machine backup function. BRIEF DESCRIPTION OF DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can be obtained without creative labor based on these drawings.

[0038] Figure 1 An application environment diagram of the virtual machine backup method in one embodiment;

[0039] Figure 2 a flowchart of a virtual machine backup method in one embodiment;

[0040] Figure 3 a flowchart of determining a snapshot type corresponding to virtualization software in one embodiment;

[0041] Figure 4 a backup scheme corresponding to a snapshot type of external snapshot in one embodiment;

[0042] Figure 5 a disk dependency structure corresponding to a snapshot type of external snapshot in one embodiment;

[0043] Figure 6 a backup scheme corresponding to a snapshot type of external snapshot in another embodiment;

[0044] Figure 7 a virtual machine recovery flow corresponding to a snapshot type of external snapshot in one embodiment;

[0045] Figure 8 a backup scheme corresponding to a snapshot type of internal snapshot in one embodiment;

[0046] Figure 9 a structural block diagram of a virtual machine backup apparatus in one embodiment;

[0047] Figure 10 an internal structural diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the 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.

[0049] It should be noted that the terms "first", "second", and the like used herein can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "include" and "have" and any variations thereof used herein are intended to cover non-exclusive inclusion. The term "multiple" used herein refers to two or more. The term "and / or" used herein refers to one of the options or any combination of multiple options.

[0050] With the rapid development and wide application of cloud computing technology, virtual machines gradually evolve into one of the core infrastructures in modern information technology architecture. In the cloud computing environment, virtual machines (VM, Virtual Machine) as an important means of resource abstraction and isolation, carry a large amount of computing and storage tasks. Therefore, the reliability and security of cloud virtual machine data have become the focus of attention of the current academic and industrial circles.

[0051] Kernel-based Virtual Machine (KVM) is a kernel-based virtualization solution, which can realize efficient hardware emulation and I / O virtualization with QEMU (Quick Emulator). Because of its open source, stability and high customizability, KVM has become one of the virtualization technology frameworks widely used by mainstream cloud computing platforms. In the KVM architecture, QEMU plays a key role in simulating hardware environment and processing I / O requests, so the data backup function of KVM virtual machine is usually realized through the mechanism of QEMU.

[0052] In order to improve the management efficiency of virtual resources, the open source virtualization management framework Libvirt is widely used for unified scheduling and control of KVM virtualization platform. Libvirt encapsulates the interface of KVM and QEMU, provides standardized API to support virtual machine life cycle management, storage configuration and backup task scheduling operations. In actual deployment, backup operation is usually initiated by Libvirt, and the interface provided by the underlying QEMU is called to realize the snapshot and data persistence of virtual machine state.

[0053] The current mainstream backup method mostly depends on the external snapshot (external snapshot) interface provided by QEMU. However, this function is only fully implemented and optimized in the newer version of QEMU, and for the virtual machines deployed in the old version of QEMU (such as 2.x or earlier), this interface cannot be directly used to complete the hot backup operation. This version dependency limits the application scope of traditional backup scheme, and it is difficult to manage the unified backup of large-scale, multi-version heterogeneous environment.

[0054] In order to solve the above problems, the virtual machine backup method provided in the following embodiments of the present application is provided.

[0055] The virtual machine backup method provided in the embodiments of the present application can be applied to, for example Figure 1The application environment shown. Among them, the host computer 102 communicates with the server 104 through the network. The data storage system can store the data required by the server 104 to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. Among them, the host computer 102 can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers and the like. The server 104 can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0056] In an exemplary embodiment, as Figure 2 shown, a virtual machine backup method is provided, which is applied to Figure 1 the host computer 102 in the application environment as an example, including the following steps S202 to S206. Among them:

[0057] Step S202, obtaining the snapshot type of the virtualization software.

[0058] Among them, the virtualization software can provide device emulation and disk image processing functions of the virtual machine, and is the core implementation component of the snapshot function. Optionally, the virtualization software can be QEMU, which is an open source virtualization software that can support system-level and user-level emulation.

[0059] In some examples, the snapshot type of the virtualization software can include external snapshot and internal snapshot. For example, in the case of the virtualization software in the host computer being QEMU, the version number of QEMU can be detected to determine the snapshot type corresponding to the virtualization software.

[0060] Specifically, the host computer can obtain the snapshot type corresponding to the virtualization software by identifying the version number of the virtualization software and the like.

[0061] For example, as Figure 3 shown, in the initialization phase, the qemu-system-x86_64 --version command can be executed to obtain the QEMU version information in the current system, and different snapshot strategies are selected according to the version information: when the version number of QEMU is higher than or equal to 2.0 version, QEMU is in high version, at this time the snapshot type is external snapshot, and the backup of the virtual machine needs to use the external snapshot scheme; when the version number of QEMU is lower than 2.0 version, QEMU is in low version, at this time the snapshot type is internal snapshot, and the backup of the virtual machine needs to use the internal snapshot scheme.

[0062] Step S204, according to the snapshot type, copying the target copy file matching the snapshot type to the backup server to generate a backup file in the backup server;

[0063] In the case that the snapshot type is an external snapshot, the target copy file is determined based on a raw disk file or a read-only state disk file of the virtual machine; in the case that the snapshot type is an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine. Optionally, the virtual machine includes a KVM virtual machine.

[0064] Illustratively, the read-only state disk file described above can be a disk file in the virtual machine that is converted from an active state to a read-only state. The active state represents that the corresponding disk file can be used as an active disk of the virtual machine, and the read-only state represents that the corresponding disk file can be used as a read-only disk of the virtual machine.

[0065] In actual applications, the backup server can be another independent physical server device or another virtual machine, and the implementation mode of the backup server is not limited in the embodiments of the present application.

[0066] Specifically, the host machine copies the target copy file matching the snapshot type to the backup server according to the snapshot type corresponding to the current virtualization software, so as to generate a corresponding backup file in the backup server.

[0067] Illustratively, in the case that the snapshot type corresponding to the virtualization software is an external snapshot, the host machine can determine the target copy file to be a raw disk file or a disk file in a read-only state in the current virtual machine according to the disk state of the current virtual machine and the backup state of the backup server. Optionally, the backup state of the backup server can be the storage state of the backup file in the backup server, for example, whether the backup file in the backup server only includes a base backup file.

[0068] In some examples, in the case that the snapshot type of the virtualization software is an external snapshot, the host machine can determine the complete virtual machine disk file of the current virtual machine as the target copy file, and copy the target copy file to the backup server, so as to generate a backup file corresponding to the complete virtual machine disk file of the current virtual machine in the backup server.

[0069] The virtual machine backup method described above acquires the snapshot type of the virtualization software, and copies the target copy file matching the snapshot type to the backup server according to the snapshot type, so as to generate a backup file in the backup server. Through the above method, the present application can dynamically select the backup mode of the external snapshot or the internal snapshot, thereby effectively solving the compatibility problem caused by the difference in snapshot mechanism between different virtualization software versions, and ensuring the consistent operation of the backup function in multiple cloud environments.

[0070] In one of the embodiments, as Figure 4As shown, the backup file includes a base backup file; according to the snapshot type, the target copy file matching the snapshot type is copied to the backup server to generate a backup file in the backup server, including the following steps S302 to S304. Wherein:

[0071] Step S302, if the snapshot type is external snapshot, and it is determined that the base backup file does not exist in the current backup server, it is determined that the first disk file of the virtual machine is the target copy file.

[0072] Wherein, the first disk file is an original disk file configured as a read-only disk of the virtual machine. Further, the base backup file can be configured as a backup for the original disk file of the virtual machine. It can be understood that if the base backup file does not exist in the current backup server, it means that the current backup server has not yet backed up the original disk file of the virtual machine.

[0073] Exemplarily, as shown in Figure 5 When in external snapshot mode, the disk of the virtual machine can include a read-only disk and an active disk, the active disk of the virtual machine can perform a write operation based on user indication, and the active disk of the virtual machine relies on the read-only disk to achieve the function of reading the required read-only data from the read-only disk.

[0074] Specifically, in the case where the snapshot type corresponding to the virtualization software is external snapshot, if the base backup file does not exist in the current backup server, the host machine can specify the first disk file (i.e. the original disk file) of the virtual machine as the target copy file.

[0075] Step S304, copy the target copy file to the backup server to generate a base backup file in the backup server.

[0076] Specifically, the host machine can copy the specified target copy file to the backup server, so that the backup server generates a base backup file corresponding to the original disk file of the virtual machine.

[0077] In actual application, an API (Application Programming Interface) provided by Libvirt, such as virsh snapshot-create-as, can be used to create a corresponding external snapshot for the virtual machine: assuming that the original disk file of the virtual machine is base.qcow2, and an external snapshot based on the original disk file is active1.qcow2, the mirror image dependency structure of the two is as follows: base.qcow2 < active1.qcow2. At this time, the above base.qcow2 is configured as the current read-only disk of the virtual machine to serve as the historical baseline of data, and the active1.qcow2 is configured as the active disk. When performing backup, the host machine can specify the above original disk file base.qcow2 as the target copy file, and copy the target copy file to the backup server to generate a corresponding base backup file in the backup server.

[0078] In one embodiment, as Figure 6 , the backup file further includes an incremental backup file; and the method further includes the following steps S402 to S406. Wherein:

[0079] In step S402, if the snapshot type is an external snapshot, and it is determined that the base backup file exists in the current backup server, a third disk file dependent on the second disk file is created based on the second disk file currently serving as the active disk of the virtual machine.

[0080] It can be understood that when the base backup file exists in the backup server, it indicates that the backup server has already performed backup on the original disk file of the virtual machine.

[0081] In one possible implementation, when the second disk file serves as the active disk of the virtual machine, it can only depend on the first disk file (i.e. the original disk file) in the above embodiment, and the second disk file can read the read-only data in the first disk file. It can be understood that at this time, the mirror image dependency structure of the first disk file and the second disk file is as follows: base.qcow2 (first disk file / original disk file) < active1.qcow2 (second disk file).

[0082] In another possible implementation, when the second disk file serves as the active disk of the virtual machine, it can depend on a read-only snapshot chain, which can be composed of the original disk file and other incremental disk files in a read-only state and having dependency relationship, and the second disk file can read the read-only data in the read-only snapshot chain as the active disk of the virtual machine. It can be understood that at this time, multiple base backup files corresponding to the read-only snapshot chain and one or more incremental backup files can exist in the backup server.

[0083] Specifically, in the case where there is a base backup file in the backup server, the host creates a third disk file dependent on the second disk file, which is currently the active disk of the virtual machine. Exemplarily, taking the case where the second disk file only depends on the original disk file as an example, at this time the mirror dependency relationship of each disk file in the virtual machine is as follows: base.qcow2 (original disk file / first disk file) <— active1.qcow2 (second disk file) <— active2.qcow2 (third disk file).

[0084] In step S404, the second disk file is converted from the active state to the read-only state, and the third disk file is configured as the new active disk of the virtual machine.

[0085] Specifically, after the third disk file dependent on the second disk file is created, the host configures the second disk file originally as the active disk of the virtual machine to the read-only state, so that the second disk file and the disk file in the read-only disk on which the second disk file originally depends together constitute a new read-only disk (also referred to as a read-only layer) of the virtual machine; at the same time, the created third disk file is configured as a new active disk dependent on the above read-only disk.

[0086] In step S406, the second disk file is determined as a target copy file, and the target copy file is copied to the backup server to generate an incremental backup file in the backup server.

[0087] Specifically, the host specifies the second disk file currently in the read-only state as the target copy file, and copies the target copy file to the backup server, thereby generating an incremental backup file corresponding to the second disk file in the backup server.

[0088] In one embodiment, after the target copy file is copied to the backup server, the following steps S502 to S504 are further included. Wherein:

[0089] In step S502, the second disk file in the virtual machine is merged with the read-only disk file on which the second disk file depends to obtain a fourth disk file.

[0090] Exemplarily, taking QEMU as an example of the virtualization software, the qemu-img commit command can be used to merge the second disk file in the virtual machine with the read-only disk file relied by the second disk file, and form a new dependency relationship correspondingly. For example, after merging the following image dependency structure base.qcow2<—active1.qcow2<—active2.qcow2, a new image dependency structure base.qcow2*<—active2.qcow2 can be obtained, where base.qcow2* is the read-only disk file obtained by merging base.qcow2 and active1.qcow2. The qemu-img commit command can merge the upper snapshot data into the lower image, thereby shortening the snapshot chain, optimizing the disk structure, and improving the system performance and data consistency.

[0091] Specifically, the host machine can merge the second disk file in the virtual machine with the read-only disk file relied by the second disk file through the merging instruction, thereby obtaining the corresponding fourth disk file.

[0092] In step S504, the fourth disk file is configured as a new read-only disk of the virtual machine, and the third disk file is configured as an active disk of the virtual machine relying on the fourth disk file.

[0093] Specifically, after the above merging process is completed, the host machine configures the fourth disk file as a new read-only disk of the virtual machine, and configures the third disk file as an active disk of the virtual machine relying on the fourth disk file.

[0094] It can be understood that the long-term use of the incremental backup strategy in the traditional virtual machine backup scheme will cause the backup chain in the virtual machine to be continuously extended, which is easy to cause consistency risk and recovery reliability problem. Especially when an abnormality occurs in a certain intermediate node in the backup chain, the entire link may not be recovered, which increases the data recovery complexity and uncertainty after system failure. The backup merging mechanism described above is used in the embodiments of the present application to effectively control the length of the incremental snapshot chain, avoid recovery failure or performance degradation caused by too long backup chain in the virtual machine, and thus improve the stability and security of the virtual machine backup.

[0095] In one of the embodiments, as shown in Figure 7 the method further includes steps S502 to S508. Wherein:

[0096] In step S502, in response to receiving the disk recovery instruction and the snapshot type being an external snapshot, a backup file is obtained from a backup server.

[0097] The backup file can include a base backup file and an incremental backup file.

[0098] Specifically, the host machine, in response to receiving the disk recovery instruction from the user, copies the corresponding backup file in the backup server back to the host machine in the case that the snapshot type corresponding to the current virtual machine software is an external snapshot.

[0099] In step S504, if the backup file only includes the base backup file, the base backup file is determined as the base disk file.

[0100] The base disk file can be used as a file basis for creating a new virtual machine by the host machine.

[0101] Specifically, when it is determined that the backup file currently copied back to the host machine only includes the base backup file, the host machine specifies the base backup file as the base disk file.

[0102] In step S506, if the backup file includes the base backup file and the incremental backup file, the base backup file and the incremental backup file are merged to obtain the base disk file.

[0103] Specifically, when it is determined that the backup file currently copied back to the host machine includes the base backup file and one or more incremental backup files, the host machine merges the base backup file and the one or more incremental backup files, and specifies the merged disk file as the base disk file.

[0104] In step S508, a new virtual machine is created based on the base disk file.

[0105] The new virtual machine can specify the base disk file as its original disk file.

[0106] Specifically, the host machine can create a new virtual machine that specifies the base disk file obtained in the above steps as its original disk file, thereby realizing the virtual machine recovery function.

[0107] For example, taking the virtualization software as QEMU, and taking the backup file in the backup server as including the base backup file and the incremental backup file, an exemplary virtual machine recovery process is as follows:

[0108] First, the host computer copies the base backup file base.qcow2 and the incremental backup file active.qcow2 backed up in the backup server back to the host computer; second, the backing file of the incremental backup file active.qcow2 is specified as the base backup file base.qcow2 by using the qemu-img rebase command; then, the content of the incremental backup file active.qcow2 is merged into the base backup file base.qcow2 by using the qemu-img commit command; then, the incremental backup file active.qcow2 copied back to the host computer is deleted, and only the merged base backup file base.qcow2 is retained, which is the required base disk file; then, the virtual machine XML configuration file is set, so that the disk device of the new virtual machine points to the base disk file; finally, the host computer creates a new virtual machine according to the virtual machine XML configuration file, and cleans up the temporary resources generated in the recovery process, so as to complete the virtual machine recovery process. Optionally, one or more incremental backup files can be included in the backup file, and the number of incremental backup files is not limited in the embodiments of the application.

[0109] In one embodiment, as shown in FIG. 6, according to the snapshot type, the target copy file matching the snapshot type is copied to the backup server to generate a backup file in the backup server, including the following steps S602 to S604. Wherein: Figure 8

[0110] S602, if the snapshot type is an internal snapshot, instructing the current virtual machine disk file to generate an internal snapshot point.

[0111] It can be understood that some virtualization software (for example, low version of QEMU) does not support external snapshot mechanism, and only internal snapshot (internal snapshot) scheme can be used.

[0112] Specifically, in the case where the snapshot type corresponding to the current virtualization software is an internal snapshot, the host computer instructs the current virtual machine disk file of the virtual machine to create an internal snapshot point.

[0113] S604, determining the complete virtual machine disk file of the current virtual machine as a target copy file, copying the target copy file to the backup server, and rolling back the virtual machine disk file to the internal snapshot point.

[0114] ​Specifically, after the internal snapshot point is created, the host machine specifies the current virtual machine complete virtual machine disk file as a target copy file, and copies the target copy file to the backup server, at this time the backup file generated in the backup server includes the complete virtual machine disk file corresponding to the internal snapshot point. Then, the host machine rolls back the current virtual machine disk file of the virtual machine to the internal snapshot point to ensure backup consistency.

[0115] Exemplarily, taking the low version (version number <2.0) QEMU of the virtualization software in the host machine as an example, the host machine can create the internal snapshot point snap1 of the current virtual machine disk file through the virsh snapshot-create command, then completely copy the current virtual machine disk file vm.qcow2 to the backup server, and use the virsh snapshot-revert command to roll back the virtual machine disk file vm.qcow2 in the virtual machine to the snapshot point snap1 to ensure backup consistency. The embodiment of the application realizes complete coverage of the backup function in the low version QEMU environment, thereby avoiding the problem of incompatibility of external snapshots, and effectively improving the compatibility of the backup function.

[0116] In one of the embodiments, the method further includes the following steps S702 to S704. Wherein:

[0117] Step S702, in response to receiving the disk recovery instruction and the snapshot type being an internal snapshot, obtaining the backup file of the specified internal snapshot point from the backup server.

[0118] Specifically, the host machine copies the backup file of the specified internal snapshot point from the backup server to the host machine in response to receiving the disk recovery instruction from the user, in the case that the snapshot type corresponding to the current virtualization software is an internal snapshot.

[0119] Step S704, creating a new virtual machine based on the backup file.

[0120] Specifically, the host machine sets the virtual machine XML configuration file to point the disk device to the backup file of the specified internal snapshot point, then creates a new virtual machine based on the virtual machine XML configuration file and the backup file, and cleans up the temporary resources generated in the recovery process, thereby completing the virtual machine recovery process.

[0121] The virtual machine backup method described in the above embodiments at least includes the following beneficial technical effects:

[0122] 1. Improve system compatibility and adaptability: by automatically identifying the snapshot type corresponding to the virtual machine software, dynamically selecting external or internal snapshot mode, solving the compatibility problem caused by the difference of snapshot mechanism, ensuring the consistent operation of backup function in various cloud environments.

[0123] 2. Reduce backup chain risk and enhance data reliability: external snapshot combined with commit merge mechanism, effectively control the length of incremental snapshot chain, avoid the recovery failure or performance degradation caused by too long backup chain, improve the stability and security of backup.

[0124] 3. Enhance the usability of low version QEMU: using internal snapshot + whole disk copy + snapshot rollback, make the early version of QEMU can realize high integrity virtual machine backup and recovery without external snapshot support, extend the service life and adaptation range of the system.

[0125] 4. Support continuous incremental backup, save storage resources: for high version QEMU, the system can generate incremental snapshot continuously, only copy the changed data, effectively reduce the storage overhead, improve the backup efficiency.

[0126] In summary, the virtual machine backup method provided by the present application can face KVM virtual machine, has high compatibility, low coupling degree, can adapt to old QEMU version, and has stability and maintainability, which has important technical value and practical significance for guaranteeing the data security of virtual machine in cloud environment and improving the availability of cloud platform.

[0127] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps has no strict order limitation, and these steps can be executed in other order. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which 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 sequential, but can be alternately or alternately executed with at least part of other steps or steps or stages in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by combination belong to the scope of protection of the present application.

[0128] Based on the same inventive concept, the embodiment of the present application further provides a virtual machine backup device for implementing the virtual machine backup method as mentioned above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitation in one or more virtual machine backup device embodiments provided below can refer to the limitation of the virtual machine backup method in the above, which will not be repeated here.

[0129] In one exemplary embodiment, as shown in Figure 9 The present application provides a virtual machine disk backup and restoration device 900, the device 900 comprises:

[0130] A snapshot type acquisition module 902 is configured to acquire the snapshot type of the virtualization software.

[0131] A backup module 904 is configured to copy the target copy file matching the snapshot type to the backup server according to the snapshot type, so as to generate a backup file in the backup server.

[0132] In the case of an external snapshot, the target copy file is determined based on the original disk file of the virtual machine or the disk file in the read-only state; in the case of an internal snapshot, the target copy file is the complete virtual machine disk file of the virtual machine.

[0133] In one embodiment, the backup file comprises a basic backup file; the backup module 904 is further configured to:

[0134] If the snapshot type is an external snapshot and it is determined that the basic backup file does not exist in the current backup server, the first disk file of the virtual machine is determined as the target copy file; the first disk file is the original disk file configured as the read-only disk of the virtual machine.

[0135] The target copy file is copied to the backup server to generate the basic backup file in the backup server.

[0136] In one embodiment, the backup file further comprises an incremental backup file; the device 900 further comprises:

[0137] A third disk file creation module is configured to, if the snapshot type is an external snapshot and it is determined that the basic backup file exists in the current backup server, create a third disk file dependent on the second disk file based on the second disk file currently serving as the active disk of the virtual machine.

[0138] A first state conversion module is configured to convert the second disk file from the active state to the read-only state, and configure the third disk file as the new active disk of the virtual machine.

[0139] The first copying module is configured to determine the second disk file as a target copy file, and copy the target copy file to the backup server to generate an incremental backup file in the backup server.

[0140] In one of the embodiments, the apparatus 900 further includes:

[0141] The first merging module is configured to merge the second disk file in the virtual machine with the read-only disk file relied on by the second disk file to obtain a fourth disk file.

[0142] The second state converting module is configured to configure the fourth disk file as a new read-only disk of the virtual machine, and configure the third disk file as an active disk of the virtual machine relying on the fourth disk file.

[0143] In one of the embodiments, the apparatus 900 further includes:

[0144] The first backup file obtaining module is configured to, in response to receiving the disk recovery instruction and the snapshot type being the external snapshot, obtain the backup file from the backup server.

[0145] The base disk file determining module is configured to, if the backup file only includes the base backup file, determine the base backup file as the base disk file.

[0146] The second merging module is configured to, if the backup file includes the base backup file and the incremental backup file, merge the base backup file and the incremental backup file to obtain the base disk file.

[0147] The first virtual machine generating module is configured to create a new virtual machine based on the base disk file.

[0148] In one of the embodiments, the backup module 904 is further configured to:

[0149] If the snapshot type is the internal snapshot, instruct the current virtual machine disk file to generate an internal snapshot point.

[0150] Determine the complete virtual machine disk file of the current virtual machine as a target copy file, copy the target copy file to the backup server, and roll back the virtual machine disk file to the internal snapshot point.

[0151] In one of the embodiments, the apparatus 900 further includes:

[0152] The second backup file obtaining module is configured to, in response to receiving the disk recovery instruction and the snapshot type being the internal snapshot, obtain the backup file of the specified internal snapshot point from the backup server.

[0153] The second virtual machine generating module is configured to create a new virtual machine based on the backup file.

[0154] Each module in the virtual machine backup apparatus can be implemented by software, hardware, and combinations thereof, in whole or in part. Each module can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so as to be called and executed by a processor to perform operations corresponding to each module.

[0155] In an exemplary embodiment, a computer device is provided, which can be a host computer, and an internal structure diagram thereof can be as shown in Figure 10 The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. The processor of the computer device is configured 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 and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to perform wired or wireless communication with an external host computer, and the wireless communication can be achieved through WIFI, mobile cellular network, near field communication (NFC), or other technologies. The computer program is executed by the processor to implement a virtual machine backup method. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball, or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad, or mouse, etc.

[0156] Those skilled in the art can understand that Figure 10 The structure shown in the above description is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. Specifically, the computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0157] In an exemplary embodiment, the present application further provides a computer device including a memory and a processor, and the memory stores a computer program, and the processor executes the computer program to implement the following steps:

[0158] Step A, obtaining a snapshot type of virtualization software;

[0159] Step B, copying the target copy file of the matched snapshot type to the backup server to generate a backup file in the backup server according to the snapshot type;

[0160] Wherein, in the case of the snapshot type being an external snapshot, the target copy file is determined based on a raw disk file or a read-only state disk file of the virtual machine; in the case of the snapshot type being an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine.

[0161] In one of the embodiments, the processor, when executing the computer program, further implements the following steps:

[0162] If the snapshot type is an external snapshot and it is determined that the base backup file does not exist in the current backup server, the first disk file of the virtual machine is determined as the target copy file; the first disk file is a raw disk file configured as a read-only disk of the virtual machine; the target copy file is copied to the backup server to generate the base backup file in the backup server.

[0163] In one of the embodiments, the processor, when executing the computer program, further implements the following steps:

[0164] If the snapshot type is an external snapshot and it is determined that the base backup file exists in the current backup server, a third disk file dependent on the second disk file is created based on the second disk file currently serving as the active disk of the virtual machine; the second disk file is converted from the active state to the read-only state, and the third disk file is configured as the new active disk of the virtual machine; the second disk file is determined as the target copy file, and the target copy file is copied to the backup server to generate the incremental backup file in the backup server.

[0165] In one of the embodiments, the processor, when executing the computer program, further implements the following steps:

[0166] The second disk file in the virtual machine is merged with the read-only disk file on which the second disk file depends to obtain a fourth disk file; the fourth disk file is configured as the new read-only disk of the virtual machine, and the third disk file is configured as the active disk of the virtual machine dependent on the fourth disk file.

[0167] In one of the embodiments, the processor, when executing the computer program, further implements the following steps:

[0168] In response to receiving the disk recovery instruction and the snapshot type being an external snapshot, the backup file is obtained from the backup server; if the backup file only includes the base backup file, the base backup file is determined as the base disk file; if the backup file includes the base backup file and the incremental backup file, the base backup file and the incremental backup file are merged to obtain the base disk file.

[0169] Based on the base disk file, a new virtual machine is created.

[0170] In one of the embodiments, the processor, when executing the computer program, also implements the following steps:

[0171] If the snapshot type is an internal snapshot, instructing the current virtual machine disk file to generate an internal snapshot point; determining the current virtual machine complete virtual machine disk file as a target copy file, copying the target copy file to a backup server, and rolling back the virtual machine disk file to the internal snapshot point.

[0172] In one of the embodiments, the processor, when executing the computer program, also implements the following steps:

[0173] In response to receiving the disk recovery instruction and the snapshot type being an internal snapshot, obtaining a backup file of the specified internal snapshot point from the backup server; based on the backup file, creating a new virtual machine.

[0174] In one of the embodiments, the present application also provides a computer readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps in the above method embodiments.

[0175] In one of the embodiments, the present application also provides a computer program product, which includes a computer program, and the computer program, when executed by a processor, implements the steps in the above method embodiments.

[0176] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to 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. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.

[0177] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present application.

[0178] The above-described embodiments are merely illustrative of several embodiments of the present application, which are described in more detail and in a specific manner, but should not be construed as limiting the scope of the patent of the present application. It should be noted that, for those of ordinary skill in the art, several modifications 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 should be subject to the appended claims.

Claims

1. A virtual machine backup method characterized by, The method comprises: acquiring a snapshot type of virtualization software; copying a target copy file matching the snapshot type to a backup server according to the snapshot type to generate a backup file in the backup server; wherein, in a case that the snapshot type is an external snapshot, the target copy file is determined based on a raw disk file or a read-only state disk file of a virtual machine; in a case that the snapshot type is an internal snapshot, the target copy file is a complete virtual machine disk file of the virtual machine.

2. The virtual machine backup method according to claim 1, wherein, The backup file comprises a basic backup file; and the copying of the target copy file matching the snapshot type to the backup server according to the snapshot type to generate the backup file in the backup server comprises: if the snapshot type is the external snapshot and it is determined that the basic backup file does not exist in the backup server currently, determining a first disk file of the virtual machine as the target copy file; the first disk file is the raw disk file configured as a read-only disk of the virtual machine; copying the target copy file to the backup server to generate the basic backup file in the backup server.

3. The virtual machine backup method according to claim 2, characterized by, The backup file further comprises an incremental backup file; and the method further comprises: if the snapshot type is the external snapshot and it is determined that the basic backup file exists in the backup server currently, creating a third disk file dependent on a second disk file based on the second disk file currently serving as an active disk of the virtual machine; converting the second disk file from an active state to a read-only state and configuring the third disk file as a new active disk of the virtual machine; determining the second disk file as the target copy file and copying the target copy file to the backup server to generate the incremental backup file in the backup server.

4. The virtual machine backup method according to claim 3, characterized by, After the copying of the target copy file to the backup server, the method further comprises: merging the second disk file in the virtual machine with a read-only disk file on which the second disk file depends to obtain a fourth disk file; configuring the fourth disk file as a new read-only disk of the virtual machine and configuring the third disk file as an active disk of the virtual machine dependent on the fourth disk file.

5. The virtual machine backup method according to claim 3, wherein, The method further comprises: in response to receiving a disk recovery instruction and the snapshot type being the external snapshot, acquiring the backup file from the backup server; if the backup file only comprises the basic backup file, determining the basic backup file as a basic disk file; if the backup file comprises the basic backup file and the incremental backup file, merging the basic backup file and the incremental backup file to obtain the basic disk file; creating a second virtual machine based on the basic disk file.

6. The virtual machine backup method according to claim 1, wherein, The copying of the target copy file matching the snapshot type to the backup server according to the snapshot type to generate the backup file in the backup server comprises: if the snapshot type is the internal snapshot, indicating that the current virtual machine disk file generates an internal snapshot point; determining that the current virtual machine complete virtual machine disk file is the target copy file, copying the target copy file to the backup server, and rolling back the virtual machine disk file to the internal snapshot point.

7. The virtual machine backup method according to claim 1, wherein, The method further comprises: in response to receiving a disk recovery instruction and the snapshot type being the internal snapshot, obtaining the backup file of the specified internal snapshot point from the backup server; creating a third virtual machine based on the backup file.

8. A virtual machine disk backup restoration apparatus characterized by comprising: The device comprises: a snapshot type obtaining module configured to obtain a snapshot type of virtualization software; a backup module configured to copy a target copy file matching the snapshot type to a backup server to generate a backup file in the backup server according to the snapshot type; wherein, in the case that the snapshot type is an external snapshot, the target copy file is determined based on an original disk file of a virtual machine or a read-only state disk file; in the case that the snapshot type is an internal snapshot, the target copy file is a virtual machine disk file complete for the virtual machine. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-8 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for backing up and restoring Windows virtual machine system disk

    CN103729264A

  • Virtual machine disk backup method and apparatus

    CN107544871A

  • Online incremental backup and recovery method and application of local storage virtual machine

    CN113918385A

  • Backup method, disaster recovery method, device and equipment of virtual machine

    CN115098299A

  • Virtual machine backup and recovery method based on vSAN hyper-converged virtualization platform

    CN116185720A