Virtual machine backup method, system, device and readable storage medium

CN116841799BActive Publication Date: 2026-11-03ANCHAO CLOUD SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310799500.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2026-11-03
Estimated Expiration
2043-06-30

AI Technical Summary

Technical Problem

Existing virtual machine backup methods can only perform backups when the machine is powered on, and cannot recognize virtual machines that are powered off. Furthermore, after creating a new external snapshot on an old snapshot, they cannot create incremental backups for newly generated dirty data from the virtual machine, resulting in missing backup data.

Method used

It uses a persistent bitmap created based on backup commands, combined with qemu-img rebase operations for full backup, and uses persistent bitmap and qemu-nbd operations for incremental backup. It supports virtual machine backup in a powered-off state and avoids data loss caused by old snapshots not participating in incremental backup.

Benefits of technology

It enables virtual machine backups to be performed while the system is powered off, preventing data loss due to disk failure, avoiding missing backup data, and improving the convenience and completeness of backup operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116841799B_ABST
    Figure CN116841799B_ABST
Patent Text Reader

Abstract

The application discloses a virtual machine backup method, system, device and readable storage medium, and the virtual machine backup method comprises the following steps: based on a backup command, a persistent bitmap is created based on an external snapshot in which the virtual machine is currently in an active state or an original disk in which the virtual machine is in an active state; based on a qemu-img base operation, full backup is performed on the disk of the virtual machine in a shutdown state; based on the persistent bitmap and a qemu-nbd operation, dirty data after backup is acquired, and incremental backup is performed on the disk of the virtual machine. The virtual machine backup method provided by the application enables the backup of the virtual machine to be performed in a shutdown state, effectively prevents data damage caused by virtual machine disk damage during shutdown, and enables the backup operation to be performed after shutdown without restarting the virtual machine, so that the backup operation is more convenient. Meanwhile, the problem that the bitmap created on the old snapshot cannot create incremental backup for the newly generated dirty data of the virtual machine after a new external snapshot is created on a disk is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information technology, and in particular to a virtual machine backup method, system, device, and readable storage medium. Background Technology

[0002] Virtualization is a physical model that fully utilizes physical resources and enables the sharing of computing resources via the Internet. As virtualization technology continues to develop, the virtual machine (VM) is the focal point of its implementation. During runtime, the host machine (the machine hosting the VM) virtualizes various hardware units for the VM, such as VM memory and VM hard disks. Data in VM memory is managed by the VM itself, while data on the VM hard disk is stored and managed by the host machine.

[0003] To maintain the continuity and stability of virtual machine operations and avoid data loss due to unforeseen circumstances, ensuring effective and timely backups of virtual machines during use has become a hot topic. In existing technologies, QEMU's drive-backup solution can be used for real-time disk backups. This means that while the virtual machine is powered on, a snapshot chain of qcow2 formatted disk files and a bitmap associated with an external snapshot can be used to perform full and incremental backups of the disk.

[0004] However, existing virtual machine backup methods only support backup tasks when the virtual machine is powered on. When the virtual machine is powered off, the corresponding command will not be able to recognize the virtual machine. Furthermore, bitmaps can only be bound to a specified snapshot file (or original disk file). When a new external snapshot is created on a disk, the bitmap created on the old snapshot will not be able to create incremental backups for newly generated dirty data of the virtual machine.

[0005] Therefore, in order to address the above-mentioned technical problems, it is necessary to provide a virtual machine backup method, system, device, and readable storage medium.

[0006] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention

[0007] The purpose of this invention is to provide a virtual machine backup method, system, device, and readable storage medium that can perform backup tasks in a powered-off state, while avoiding the loss of backup data caused by old snapshots not participating in incremental backups.

[0008] To achieve the above objectives, the technical solution provided by the present invention is as follows:

[0009] In a first aspect, the present invention provides a virtual machine backup method, comprising:

[0010] Based on the backup command, a persistent bitmap is created from an external snapshot of the virtual machine that is currently in an active state or from the original disk that is currently in an active state;

[0011] Based on the rebase operation of qemu-img, a full backup of the disk of a virtual machine in a powered-off state is performed.

[0012] Based on the persistent bitmap and qemu-nbd operations, the backed-up dirty data is obtained, and incremental backups are performed on the virtual machine's disk.

[0013] In one or more implementations, the qemu-img-based rebase operation, which performs a full backup of the disk of a virtual machine in a powered-off state, includes:

[0014] If the external snapshot exists, a backup file is created, and the backend image file of the backup file is pointed to the last created external snapshot of the virtual machine.

[0015] If no external snapshot exists, a backup file will be created, and the backend image file of the backup file will be pointed to the original disk.

[0016] Perform a rebase operation on the backup file and specify the backend image file as an empty string.

[0017] In one or more embodiments, the step of obtaining the backed-up dirty data based on the persistent bitmap and qemu-nbd operations, and performing incremental backup of the virtual machine's disk, includes:

[0018] If no new external snapshot was created after the last backup, the dirty data after the backup is obtained, and an incremental backup is performed on the virtual machine disk.

[0019] If a new external snapshot was created after the last backup, the dirty data after the backup is obtained, and an incremental backup is performed on the virtual machine disk.

[0020] In one or more embodiments, the step of acquiring the dirty data after the backup and performing an incremental backup of the virtual machine disk if no new external snapshot has been created since the last backup includes:

[0021] If an external snapshot exists, the dirty data in the persistent bitmap bound to the last created virtual machine external snapshot is obtained as incremental backup data based on the qemu-nbd command;

[0022] If no external snapshot exists, the dirty data in the persistent bitmap bound to the original disk is used as incremental backup data.

[0023] Write the incremental backup data into the backup file.

[0024] In one or more embodiments, if a new external snapshot was created after the last backup, acquiring the dirty data after the backup and performing an incremental backup of the virtual machine disk includes:

[0025] If an external snapshot existed during the last backup, the dirty data in the persistent bitmap bound to the virtual machine external snapshot last created during the last backup is obtained based on the qemu-nbd command, and the dirty data is written to the backup file.

[0026] If no external snapshot existed during the last backup, the dirty data in the persistent bitmap bound to the original disk is obtained based on the qemu-nbd command and written to the backup file.

[0027] The data from the external snapshot created after the last backup is merged with the backup file data through the rebase operation of qemu-img.

[0028] In one or more embodiments, the step of merging the data of the external snapshot created after the last backup with the backup file data through the qemu-img rebase operation includes:

[0029] Create a new backup file, and use a rebase operation to point the backend image file of the new backup file to an external snapshot created after the last backup.

[0030] Based on the rebase operation, the backend image file is specified as the parent snapshot of the external snapshot created after backup, and the data of the external snapshot created after backup is merged into the newly created backup file;

[0031] The rebase operation specifies that the backend image file is the original backup file;

[0032] Based on the rebase operation, the backend image file is specified as an empty string, and the data of the original backup file is merged into the newly created backup file.

[0033] In one or more embodiments, the method further includes:

[0034] Based on the drive-backup backup command, a persistent bitmap is created for a virtual machine in the boot state using an external snapshot of the virtual machine that is currently in an active state or the original disk that is in an active state, and a full backup of the disk is performed.

[0035] Based on the qemu-nbd command, the dirty data of the persistent bitmap bound to the external snapshot that was in an active state at the time of the last backup and the data of the external snapshot that was not in an active state after the last backup are written to the backup file;

[0036] Create a new backup file, obtain the data of the currently active external snapshot based on the drive-backup backup command, write it to the new backup file, and create a persistent bitmap for the currently active external snapshot;

[0037] The backup file is merged into the newly created backup file through a rebase operation, thus completing the incremental backup.

[0038] Secondly, the present invention provides a virtual machine backup system, comprising:

[0039] A creation module is used to create a persistent bitmap based on a backup command, using an external snapshot of the virtual machine that is currently in an active state or the original disk that is currently in an active state.

[0040] The full backup module is used for rebase operations based on qemu-img to perform a full backup of the disk of a virtual machine in a powered-off state.

[0041] The incremental backup module is used to obtain the backed-up dirty data based on the persistent bitmap and qemu-nbd operations, and to perform incremental backups on the virtual machine's disk.

[0042] Thirdly, the present invention provides a computer device comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the virtual machine backup method by executing the computer instructions.

[0043] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the virtual machine backup method.

[0044] Compared with existing technologies, the virtual machine backup method provided by this invention creates a persistent bitmap based on a backup command using an external snapshot of the virtual machine currently in an active state or the original disk in an active state; performs a full backup of the virtual machine's disk in a powered-off state based on the qemu-img rebase operation; and performs an incremental backup of the virtual machine's disk based on the persistent bitmap and the qemu-nbd operation to obtain the backed-up dirty data. This virtual machine backup method has the following advantages:

[0045] (1) The virtual machine backup method provided by this invention supports backup in a powered-off state, preventing data loss due to virtual machine disk damage after shutdown. Backup operations can be performed after shutdown without restarting the virtual machine, making backup operations more convenient.

[0046] (2) The virtual machine backup method provided by this invention avoids the situation where, after a new external snapshot is created on a disk, the bitmap created on the old snapshot cannot create incremental backups for newly generated dirty data in the virtual machine. Dirty data recorded in the old snapshot bitmap can be written to the backup file to prevent missing backup data. Attached Figure Description

[0047] Figure 1 This is a schematic diagram illustrating an application scenario of the virtual machine backup method according to one embodiment of the present invention;

[0048] Figure 2 This is a schematic diagram of the virtual machine backup process in one embodiment of the present invention;

[0049] Figure 3 This is a structural block diagram of a virtual machine backup system according to one embodiment of the present invention;

[0050] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0051] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but it should be understood that the scope of protection of the present invention is not limited to the specific embodiments.

[0052] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprises" shall be understood to include the stated elements or components without excluding other elements or other components.

[0053] To facilitate understanding of the technical solutions of this application, the technical terms that may appear in this invention will be explained in detail below.

[0054] backingfile: A read-only qcow2 format backend image file.

[0055] Snapshot: A fully usable copy of a specified set of data, which includes an image of the data at a specific point in time (the point at which the copy begins). A snapshot can be a copy of the data it represents, or a replica of the data.

[0056] External snapshots: Snapshots are stored in a separate external file. The snapshots mentioned in this article all belong to external snapshots.

[0057] Bitmap: Also known as a dirty bitmap, it marks dirty data added to a disk file over a certain period of time. It is an advanced feature supported by QEMU, and the bitmap is stored in memory. It supports any disk format, such as qcow2, raw, etc.

[0058] Persistent dirty bitmap: A persistent bitmap, an improved version of dirty bitmap, is recorded on disk. When the virtual machine is shut down, the persistent dirty bitmap will not disappear. Persistent dirty bitmap is supported from version 2.10 onwards.

[0059] drive-backup: drive-backup is a real-time disk backup solution provided by qemu, which can use snapshot chains of qcow2 format disk files and bitmaps associated with external snapshots to perform full and incremental backups of disks.

[0060] QEMU: QEMU is a processor emulation software distributed under the GPL license, supporting multiple architectures by default. It can emulate various architectures, is scalable, allows for custom instruction sets, is open-source, portable, and boasts fast simulation speeds. On x86 architectures supporting hardware virtualization, it can use KVM acceleration combined with the kernel's KSM large page backup memory, achieving speeds and stability far exceeding VMware ESX, significantly increasing emulation speed. Some programs can even run in real-time. It can run Linux programs on other platforms, store and restore runtime states (such as running programs), and virtualize network cards.

[0061] Virtual machine (VM): A virtual machine is a complete computer system simulated by software, possessing full hardware system functionality and running in a completely isolated environment. Any task that can be performed on a physical computer can also be performed in a VM. When creating a VM, a portion of the physical machine's hard drive and memory capacity is used as the VM's hard drive and memory capacity. Each VM has its own independent CMOS, hard drive, and operating system, and can be operated just like a physical machine.

[0062] qcow2 is an image format for QEMU, short for "QEMU copy on write," and can be managed through qemu-img. qcow2 is a virtual block device with a defined structure and features such as reduced storage space, snapshots, and encryption.

[0063] qemu-nbd: NBD stands for Network Block Device. As the name suggests, NBD allows users to access a block device or device image over a network. qemu-nbd specifically refers to the mounting of block devices or files using NBD within the QEMU virtualization program.

[0064] qemu-img: A disk imaging utility in the QEMU virtualization program. qemu-img can create and view qcow2 images. It also supports snapshot creation, image conversion, and parent image support.

[0065] Please refer to Figure 1 The diagram illustrates an application scenario of the virtual machine backup method provided by this invention. Figure 1 The illustrated implementation scenario includes a terminal 101 requiring data backup services and a data storage server 102 with virtual machine data backup capabilities. Specifically, when terminal 101 requires data backup services, it can use the data storage server 102, based on a backup command, to create a persistent bitmap using an external snapshot of the virtual machine currently in an active state or the original disk in an active state, and perform a full backup operation. Further, based on the persistent bitmap, it obtains the backed-up dirty data and performs an incremental backup of the virtual machine disk.

[0066] The virtual machine backup method of this invention can be applied to the virtual machine backup system of this invention. This virtual machine backup system can be configured on a terminal. The terminal can include, but is not limited to, PCs (Personal Computers), PDAs (Tablet Computers), smartphones, smart wearable devices, etc.

[0067] The terminal can establish a communication connection with various servers through network 103, and the network can be a wireless network or a wired network, which is not limited in this embodiment of the invention.

[0068] The data to be backed up may include, but is not limited to: file data (Word, Excel, PPT, etc.), image data (photos, images, etc.), audio data (music, voice, etc.), video data (animations, recordings, etc.).

[0069] The data storage server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0070] Please refer to Figure 2 The diagram shown illustrates a virtual machine backup process according to an embodiment of the present invention. The virtual machine backup method specifically includes the following steps:

[0071] S201: Based on the backup command, create a persistent bitmap using an external snapshot of the virtual machine that is currently in an active state or the original disk that is currently in an active state;

[0072] It should be noted that the external snapshot in an active state refers to the state of the last created external snapshot when the system is powered on. When a new snapshot is created, it will also be in an active state when the system is powered on, and the original active external snapshot will lose that state. If no external snapshot exists, the original disk is considered to be in an active state.

[0073] It should also be noted that in this technical solution, the disk refers to a chain of qcow2 files containing parent-child relationships, which corresponds to all the data on a virtual machine disk, while the original disk refers to a qcow2 file corresponding to the virtual machine disk.

[0074] S202: Based on the rebase operation of qemu-img, perform a full backup of the disk of the virtual machine in the shutdown state;

[0075] In an exemplary embodiment, the rebase operation based on qemu-img to perform a full backup of the disk of a virtual machine in a powered-off state includes: if the external snapshot exists, creating a backup file and pointing the backend image file of the backup file to the last created external snapshot of the virtual machine; if the external snapshot does not currently exist, creating a backup file and pointing the backend image file of the backup file to the original disk; performing a rebase operation on the backup file and specifying the backend image file as an empty string.

[0076] For example, the backup file is backup.qcow2. Using the qemu-img command, the backend image file of the backup file is pointed to the external snapshot [B] which is in an active state. Then, a rebase operation is performed on the backup file. When the specified backingfile is an empty string, the data in [A][B] will be automatically merged into the backup file. Therefore, after the rebase operation is completed, [backup.qcow2] is the required full backup file.

[0077] S203: Based on the persistent bitmap and qemu-nbd operation, obtain the backed-up dirty data and perform incremental backup of the virtual machine's disk.

[0078] It should be noted that the step of obtaining the backed-up dirty data based on the persistent bitmap and qemu-nbd operation and performing incremental backup of the virtual machine disk includes: if no new external snapshot has been created since the last backup, obtaining the backed-up dirty data and performing incremental backup of the virtual machine disk; if a new external snapshot has been created since the last backup, obtaining the backed-up dirty data and performing incremental backup of the virtual machine disk.

[0079] In an exemplary embodiment, the step of obtaining the dirty data after the backup and performing incremental backup on the virtual machine disk if no new external snapshot has been created since the last backup includes: if an external snapshot exists, obtaining the dirty data in the persistent bitmap bound to the last created virtual machine external snapshot as incremental backup data based on the qemu-nbd command; if no external snapshot exists, obtaining the dirty data in the persistent bitmap bound to the original disk as incremental backup data; and writing the incremental backup data into the backup file.

[0080] It should be noted that if no new external snapshot was created after the last backup, all newly added data after the last backup is considered to be recorded as dirty data in the persistent bitmap. If there was no external snapshot at the time of the last backup, the persistent bitmap is bound to the original virtual machine disk; otherwise, it is bound to the last external snapshot created based on the time of the last backup. In this case, incremental backups of the virtual machine disk only need to retrieve the dirty data recorded in the external snapshot or the original virtual machine disk after the backup and write it to the backup file.

[0081] For example, the server uses qemu-nbd, and the client uses libnbd to connect. The BlockStatus interface is used to obtain the status of each data block according to a specified size, filter and read dirty data, and then write it to the incremental backup file [backup.qcow2].

[0082] In another exemplary embodiment, the step of obtaining the dirty data after the backup and performing incremental backup of the virtual machine disk if a new external snapshot was created after the last backup includes: if an external snapshot existed at the time of the last backup, obtaining the dirty data in the persistent bitmap bound to the last external snapshot of the virtual machine created at the time of the last backup based on the qemu-nbd command and writing the dirty data to the backup file; if no external snapshot existed at the time of the last backup, obtaining the dirty data in the persistent bitmap bound to the original disk based on the qemu-nbd command and writing the dirty data to the backup file; and merging the data of the external snapshot created after the last backup with the data of the backup file through the rebase operation of qemu-img.

[0083] Specifically, the rebase operation using qemu-img to merge the data of the external snapshot created after the last backup with the backup file data includes: creating a new backup file; using a rebase operation to point the backend image file of the new backup file to the external snapshot created after the last backup; specifying the backend image file as the parent snapshot of the external snapshot created after the backup based on the rebase operation; merging the data of the external snapshot created after the backup into the new backup file; specifying the backend image file as the original backup file based on the rebase operation; and specifying the backend image file as an empty string based on the rebase operation; merging the data of the original backup file into the new backup file.

[0084] It should be noted that since multiple external snapshots were created after the last backup, each external snapshot contains dirty data formed by new data records added to the virtual machine disk when the external snapshot was in an active state. If only the last created external snapshot is backed up during incremental backup, backup data will be missing. Therefore, if a new external snapshot was created after the last backup, it is necessary to use the `qemu-nbd` command to obtain the dirty data of the persistent bitmap bound to the last created external snapshot based on the time of the last backup, write the dirty data to the backup file, and then use the `qemu-img` rebase operation to merge the data of the external snapshot created after the last backup with the data in the backup file.

[0085] For example, if the last backup only created bitmap0 on [A], and then an external snapshot [B] was created, the incremental data includes the dirty data recorded on the persistent bitmap of [A] and all the data in [B]. The original backup file is [backup0.qcow2]. First, create a new backup file [backup.qcow2]. Following the method in the previous exemplary embodiment, obtain the dirty data recorded on bitmap0 in [A] and write it to the original backup file [backup0.qcow2]. Then, in the first rebase, merge all the data in [B] into [backup.qcow2]. In the second rebase, using unsafe mode, only point the backingfile of [backup.qcow2] to [backup0.qcow2] without merging the data. In the third rebase, merge the data of [backup0.qcow2] into [backup.qcow2]. This completes the incremental backup of [backup.qcow2].

[0086] In another specific embodiment, if the previous backup only created bitmap0 on [A], and subsequently multiple external snapshots such as [B] and [C] were created, the incremental data includes the dirty data recorded on bitmap0 bound to [A] and the data in all external snapshots created after [A]. In this case, a new backup file [backup.qcow2] should be created first. Following the method described above, the dirty data recorded on bitmap0 in [A] should be obtained and written to the original backup file [backup0.qcow2]. Then, through a rebase operation, all data in the multiple external snapshots such as [B] and [C] should be merged into [backup.qcow2]. Another rebase operation should be performed, using an unsafe mode, only pointing the backingfile of [backup.qcow2] to [backup0.qcow2] without merging the data. Finally, based on the rebase operation, the data in [backup0.qcow2] should be merged into [backup.qcow2] to complete the incremental backup.

[0087] It should also be noted that the method further includes: based on the drive-backup backup command, for a virtual machine in the boot state, creating a persistent bitmap using an external snapshot of the virtual machine currently in an active state or the original disk in an active state, and performing a full backup of the disk; based on the qemu-nbd command, obtaining the dirty data of the persistent bitmap bound to the external snapshot that was in an active state during the last backup, as well as the data of the external snapshot that was not in an active state created after the last backup, and writing it to the backup file; creating a new backup file, based on the drive-backup backup command, obtaining the data of the external snapshot that is currently in an active state, writing it to the new backup file, and creating a persistent bitmap for the external snapshot that is currently in an active state; merging the backup file into the new backup file through a rebase operation to complete the incremental backup.

[0088] When the device is powered on, the method for obtaining dirty data from external snapshots that are not in an active state can be the same as the incremental backup method described above for the powered-off state. Use qemu-nbd to obtain the dirty data recorded by the bitmap and merge all the data of those snapshots that are not bound to the bitmap into the backup file [backup.qcow2].

[0089] For the latest snapshot that is currently active, perform a full backup using the top mode of drive-backup. Write the acquired backup data to [backup.qcow2] and create a persistent bitmap1 for the latest snapshot for the next incremental backup.

[0090] After the above two steps, all incremental data since the last backup can be obtained. Then, the obtained incremental data is merged into the final incremental backup. The merging method is similar to the merging method of incremental backup in the shutdown state.

[0091] Please refer to Figure 3 As shown, based on the same inventive concept as the aforementioned virtual machine backup method, one embodiment of the present invention provides a virtual machine backup system 300, including a creation module 301, a full backup module 302, and an incremental backup module 303.

[0092] Specifically, the creation module 301 is used to create a persistent bitmap based on the backup command, using an external snapshot of the virtual machine currently in an active state or the original disk in an active state; the full backup module 302 is used to perform a full backup of the virtual machine's disk in a shutdown state based on the qemu-img rebase operation; and the incremental backup module 303 is used to obtain the backed-up dirty data based on the persistent bitmap and the qemu-nbd operation, and perform an incremental backup of the virtual machine's disk.

[0093] It should be noted that the full backup module 302 is used for rebase operation based on qemu-img to perform a full backup of the disk of the virtual machine in the shutdown state, including: if the external snapshot exists, a backup file is created and the backend image file of the backup file is pointed to the last created external snapshot of the virtual machine; if the external snapshot does not exist, a backup file is created and the backend image file of the backup file is pointed to the original disk; a rebase operation is performed on the backup file, and the backend image file is specified as an empty string.

[0094] The incremental backup module 303 is used to perform incremental backup of the virtual machine disk based on the persistent bitmap, by obtaining the dirty data after backup. This includes: if no new external snapshot was created after the last backup, and an external snapshot existed during the last backup, then using the qemu-nbd command, obtaining the dirty data in the persistent bitmap bound to the last created virtual machine external snapshot as incremental backup data; if no new external snapshot was created after the last backup, and no external snapshot existed during the last backup, then obtaining the dirty data in the persistent bitmap bound to the original disk as incremental backup data; and writing the incremental backup data to the backup file. If a new external snapshot was created after the last backup and an external snapshot existed at the time of the last backup, then based on the qemu-nbd command, dirty data in the persistent bitmap bound to the virtual machine external snapshot last created at the time of the last backup is retrieved; if a new external snapshot was created after the last backup and no external snapshot existed at the time of the last backup, then based on the qemu-nbd command, dirty data in the persistent bitmap bound to the original disk is retrieved and written to the backup file; through the rebase operation of qemu-img, the data of the external snapshot created after the last backup is merged with the data of the backup file.

[0095] It should also be noted that the creation module 301 is further used to create a persistent bitmap for a virtual machine in the boot state based on the drive-backup backup command, using either an external snapshot of the virtual machine currently in an active state or the original disk in an active state; the full backup module 302 is further used to perform a full backup of the virtual machine disk in the boot state; the incremental backup module 303 is further used to, for a virtual machine in the boot state, based on the qemu-nbd command, obtain the dirty data of the persistent bitmap bound to the external snapshot that was in an active state during the last backup and the data of the external snapshot created after the last backup; based on the drive-backup backup command, obtain the data of the external snapshot that is currently in an active state and create a persistent bitmap for the external snapshot that is currently in an active state; and through a rebase operation, merge the dirty data of the persistent bitmap bound to the external snapshot that was in an active state during the last backup and the data of the external snapshot created after the last backup into the backup file.

[0096] Please refer to Figure 4 As shown, embodiments of the present invention also provide an electronic device 400, which includes at least one processor 401, a memory 402 (e.g., non-volatile memory), a main memory 403, and a communication interface 404, wherein the at least one processor 401, the memory 402, the main memory 403, and the communication interface 404 are connected together via a bus 405. The at least one processor 401 is used to invoke at least one program instruction stored or encoded in the memory 402 to cause the at least one processor 401 to perform various operations and functions of the virtual machine backup method described in the various embodiments of this specification.

[0097] In the embodiments of this specification, electronic device 400 may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile electronic device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable electronic device, consumer electronic device, etc.

[0098] This invention also provides a computer-readable medium carrying computer-executable instructions, which, when executed by a processor, can be used to implement various operations and functions of the virtual machine backup methods described in the various embodiments of this specification.

[0099] The computer-readable medium in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0100] In this invention, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.

[0101] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0102] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, systems, and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0103] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.

Claims

1. A virtual machine backup method, characterized in that, include: Based on the backup command, a persistent bitmap is created from an external snapshot of the virtual machine that is currently in an active state or from the original disk that is currently in an active state; Based on the rebase operation of qemu-img, a full backup of the disk of a virtual machine in a powered-off state is performed. Based on the persistent bitmap and qemu-nbd operations, the backed-up dirty data is obtained, and incremental backups are performed on the virtual machine's disk. The step of obtaining the backed-up dirty data based on the persistent bitmap and qemu-nbd operation and performing incremental backup of the virtual machine disk includes: if no new external snapshot has been created since the last backup, obtaining the backed-up dirty data and performing incremental backup of the virtual machine disk; if a new external snapshot has been created since the last backup, obtaining the backed-up dirty data and performing incremental backup of the virtual machine disk. If no new external snapshot was created after the last backup, the dirty data after the backup is obtained, and incremental backup is performed on the virtual machine disk, including: if an external snapshot exists, using the qemu-nbd command, obtaining the dirty data in the persistent bitmap bound to the last created virtual machine external snapshot as incremental backup data; if no external snapshot exists, obtaining the dirty data in the persistent bitmap bound to the original disk as incremental backup data; and writing the incremental backup data into the backup file.

2. The virtual machine backup method as described in claim 1, characterized in that, The rebase operation based on qemu-img performs a full backup of the disk of the virtual machine in the shutdown state, including: If the external snapshot exists, a backup file is created, and the backend image file of the backup file is pointed to the last created external snapshot of the virtual machine. If no external snapshot exists, a backup file will be created, and the backend image file of the backup file will be pointed to the original disk. Perform a rebase operation on the backup file and specify the backend image file as an empty string.

3. The virtual machine backup method as described in claim 1, characterized in that, If a new external snapshot was created after the last backup, the dirty data from the backup is retrieved, and an incremental backup is performed on the virtual machine disk, including: If an external snapshot existed during the last backup, the dirty data in the persistent bitmap bound to the virtual machine external snapshot last created during the last backup is obtained based on the qemu-nbd command, and the dirty data is written to the backup file. If no external snapshot existed during the last backup, the dirty data in the persistent bitmap bound to the original disk is obtained based on the qemu-nbd command and written to the backup file. The data from the external snapshot created after the last backup is merged with the backup file data through the rebase operation of qemu-img.

4. The virtual machine backup method as described in claim 3, characterized in that, The rebase operation using qemu-img, which merges the data from the external snapshot created after the last backup with the backup file data, includes: Create a new backup file, and use a rebase operation to point the backend image file of the new backup file to an external snapshot created after the last backup. Based on the rebase operation, the backend image file is specified as the parent snapshot of the external snapshot created after backup, and the data of the external snapshot created after backup is merged into the newly created backup file; The rebase operation specifies that the backend image file is the original backup file; Based on the rebase operation, the backend image file is specified as an empty string, and the data of the original backup file is merged into the newly created backup file.

5. The virtual machine backup method as described in claim 1, characterized in that, The method further includes: Based on the drive-backup backup command, a persistent bitmap is created for a virtual machine in the boot state using an external snapshot of the virtual machine that is currently in an active state or the original disk that is in an active state, and a full backup of the disk is performed. Based on the qemu-nbd command, the dirty data of the persistent bitmap bound to the external snapshot that was in an active state at the time of the last backup and the data of the external snapshot that was not in an active state after the last backup are written to the backup file; Create a new backup file, obtain the data of the currently active external snapshot based on the drive-backup backup command, write it to the new backup file, and create a persistent bitmap for the currently active external snapshot; The backup file is merged into the newly created backup file through a rebase operation, thus completing the incremental backup.

6. A virtual machine backup system, employing the virtual machine backup method as described in any one of claims 1-5, characterized in that, include: A creation module is used to create a persistent bitmap based on a backup command, using an external snapshot of the virtual machine that is currently in an active state or the original disk that is currently in an active state. The full backup module is used for rebase operations based on qemu-img to perform a full backup of the virtual machine disks in the shutdown state; The incremental backup module is used to obtain the backed-up dirty data based on the persistent bitmap and qemu-nbd operations, and to perform incremental backups on the virtual machine's disk.

7. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the virtual machine backup method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the virtual machine backup method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Method for realizing hyper-v virtual machine backup based on Bitmap and application thereof

    CN114020415A

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

    CN115098299A