CN116841799A - Virtual machine backup method, system, equipment and readable storage medium - Google Patents
Virtual machine backup method, system, equipment and readable storage medium Download PDFInfo
- Publication number
- CN116841799A CN116841799A CN202310799500.5A CN202310799500A CN116841799A CN 116841799 A CN116841799 A CN 116841799A CN 202310799500 A CN202310799500 A CN 202310799500A CN 116841799 A CN116841799 A CN 116841799A
- Authority
- CN
- China
- Prior art keywords
- backup
- virtual machine
- file
- data
- disk
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 230000002085 persistent effect Effects 0.000 claims abstract description 61
- 230000006870 function Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 5
- 238000004590 computer program Methods 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 230000008859 change Effects 0.000 description 3
- 238000013500 data storage Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000004088 simulation Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
Abstract
The application discloses a virtual machine backup method, a system, equipment and a readable storage medium, wherein the virtual machine backup method comprises the following steps: based on the backup command, creating a persistent bitmap by using an external snapshot of the virtual machine in the active state or an original disk in the active state; based on the variable base operation of qemu-img, carrying out full backup on the disk of the virtual machine in the shutdown state; based on persistent bitmap and qemu-nbd operation, the backed-up dirty data is obtained, and incremental backup is carried out on the disk of the virtual machine. The virtual machine backup method provided by the application can be used for carrying out the backup of the virtual machine in the shutdown state, effectively preventing the data damage caused by the damage of the disk of the virtual machine in the shutdown period, and also can be used for carrying out the backup operation after the 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 dirty data newly generated by the virtual machine after a new external snapshot is created on one disk is avoided.
Description
Technical Field
The present application relates to the field of information technologies, and in particular, to a virtual machine backup method, system, device and readable storage medium.
Background
Virtualization is a physical model that can fully utilize physical resources to enable sharing of computing resources over the internet. While the virtualization technology is continuously developed, the virtual machine is used as a focus of implementation of the virtualization technology, and when the virtual machine runs, a host machine where the virtual machine is located, namely a host machine virtualizes various hardware units for the virtual machine, such as a virtual machine memory, a virtual machine hard disk and the like. The data in the memory of the virtual machine is managed by the virtual machine, and the data on the hard disk of the virtual machine is stored and managed by the host machine.
In order to maintain continuity and stability of service operation of the virtual machine, the problem of how to ensure that the virtual machine is effectively and timely backed up to be a current hot spot in the use process is avoided. In the prior art, a drive-backup scheme provided by qemu for carrying out real-time disk backup can be adopted, namely, under the starting state of a virtual machine, a snapshot chain of a qcow2 format disk file and a bitmap associated to an external snapshot can be used for carrying out full-quantity and incremental backup on the disk.
However, the existing virtual machine backup method only supports the backup task in the starting state of the virtual machine, the virtual machine cannot be identified when the virtual machine is backed up by using the corresponding command in the shutdown state, and the bitmap can only be bound on a designated snapshot file (or an original disk file), and after a new external snapshot is created on one disk, the bitmap created on the old snapshot cannot create incremental backup for the dirty data newly generated by the virtual machine.
Therefore, in view of the above technical problems, it is necessary to provide a virtual machine backup method, system, device and readable storage medium.
The information disclosed in this background section is only for enhancement of understanding of the general background of the application and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person of ordinary skill in the art.
Disclosure of Invention
The application aims to provide a virtual machine backup method, a system, equipment and a readable storage medium, which can execute a backup task in a shutdown state and avoid backup data loss caused by the fact that an old snapshot does not participate in incremental backup.
In order to achieve the above purpose, the technical scheme provided by the application is as follows:
in a first aspect, the present application provides a virtual machine backup method, including:
based on a backup command, creating a persistent bitmap by using an external snapshot of the virtual machine in an active state or an original disk in the active state;
based on the variable base operation of qemu-img, carrying out full backup on the disk of the virtual machine in the shutdown state;
and based on the persistent bitmap and qemu-nbd operation, acquiring the backed-up dirty data, and performing incremental backup on the disk of the virtual machine.
In one or more embodiments, the qemu-img-based variable base operation performs full backup on a disk of a virtual machine in a shutdown state, including:
if the external snapshot exists, creating a backup file, and pointing a rear-end mirror image file of the backup file to the finally created external snapshot of the virtual machine;
if no external snapshot exists currently, creating a backup file, and directing a rear-end mirror image file of the backup file to an original disk;
and performing variable base operation on the backup file, and designating the back-end mirror file as an empty string.
In one or more embodiments, the obtaining the backed up dirty data based on the persistent bitmap and qemu-nbd operations, and performing incremental backup on a disk of the virtual machine includes:
if no new external snapshot is created after the last backup, acquiring the dirty data after the backup, and performing incremental backup on the virtual machine disk;
and if a new external snapshot is created after the last backup, acquiring the backed-up dirty data, and performing incremental backup on the virtual machine disk.
In one or more embodiments, if a new external snapshot is not created after the last backup, obtaining the dirty data after the backup, and performing incremental backup on the virtual machine disk, including:
if the external snapshot exists, acquiring dirty data in a last-created persistent bitmap bound with the external snapshot of the virtual machine as incremental backup data based on a qemu-nbd command;
if the external snapshot does not exist, dirty data in the persistent bitmap bound with the original disk is obtained as incremental backup data;
and writing the incremental backup data into the backup file.
In one or more embodiments, if a new external snapshot is 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 the external snapshot exists in the last backup, acquiring dirty data in a persistent bitmap bound based on the external snapshot of the virtual machine which is finally created in the last backup based on a qemu-nbd command and writing the dirty data into a backup file;
if no external snapshot exists in the last backup, acquiring dirty data in the persistent bitmap bound with the original disk based on the qemu-nbd command and writing the dirty data into a backup file;
and merging the data of the external snapshot created after the last backup with the backup file data through the variable base operation of qemu-img.
In one or more embodiments, the merging, through the qemu-img base change operation, the data of the external snapshot created after the last backup with the backup file data includes:
newly creating a backup file, and pointing the rear-end mirror image file of the newly created backup file to an external snapshot created after the last backup through a base-changing operation;
designating the back-end mirror file as a father snapshot of the external snapshot created after backup based on the base-changing operation, and merging the data of the external snapshot created after backup to the newly-built backup file;
designating the back-end mirror image file as an original backup file based on the variable base operation;
and designating the rear-end mirror image file as an empty character string based on the variable base operation, and merging the data of the original backup file into the newly-built backup file.
In one or more embodiments, the method further comprises:
based on a drive-backup command, creating a persistent bitmap for a virtual machine in an on-state by using an external snapshot of the virtual machine in an active state or an original disk in the active state at present and performing full backup for the disk;
based on the qemu-nbd command, obtaining dirty data of the external snapshot bound persistent bitmap in the active state during the last backup and data of the external snapshot which is not in the active state and is created after the last backup, and writing the dirty data into a backup file;
newly creating a backup file, acquiring data of an external snapshot in an active state at present based on a drive-backup command, writing the newly created backup file, and creating a persistent bitmap for the external snapshot in the active state at present;
and merging the backup files into the newly-built backup files through the base changing operation, and completing incremental backup.
In a second aspect, the present application provides a virtual machine backup system, comprising:
the creation module is used for creating a persistent bitmap according to an external snapshot of the virtual machine in an active state or an original disk in the active state based on a backup command;
the full-volume backup module is used for carrying out full-volume backup on the disk of the virtual machine in the shutdown state based on the variable base operation of qemu-img;
and the incremental backup module is used for acquiring the backed-up dirty data based on the persistent bitmap and qemu-nbd operation and carrying out incremental backup on the disk of the virtual machine.
In a third aspect, the present application provides a computer device comprising: the virtual machine backup method comprises the steps of storing computer instructions in a memory and a processor, wherein the memory and the processor are in communication connection, and the processor executes the computer instructions, so that the virtual machine backup method is executed.
In a fourth aspect, the present application provides a computer-readable storage medium storing computer instructions for causing a computer to perform the virtual machine backup method.
Compared with the prior art, the virtual machine backup method provided by the application is based on a backup command, and a persistent bitmap is created by using an external snapshot of the virtual machine in an active state or an original disk in the active state; based on the variable base operation of qemu-img, carrying out full backup on the disk of the virtual machine in the shutdown state; and based on the persistent bitmap and qemu-nbd operation, acquiring the backed-up dirty data, and performing incremental backup on the disk of the virtual machine. The virtual machine backup method has the following advantages:
(1) The virtual machine backup method provided by the application supports backup in a shutdown state and prevents data loss caused by damage of a disk of the virtual machine after shutdown. The backup operation can be performed after the shutdown without restarting the virtual machine, so that the backup operation is more convenient.
(2) The virtual machine backup method provided by the application avoids that the bitmap created on the old snapshot cannot create incremental backup for dirty data newly generated by the virtual machine after a new external snapshot is created on one disk. Dirty data recorded by the old snapshot bitmap can be written into the backup file, so that the backup data is prevented from being deleted.
Drawings
FIG. 1 is a schematic diagram of an application scenario of a virtual machine backup method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of virtual machine backup in an embodiment of the application;
FIG. 3 is a block diagram illustrating a virtual machine backup system in accordance with one embodiment of the present application;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following detailed description of embodiments of the application is, therefore, to be taken in conjunction with the accompanying drawings, and it is to be understood that the scope of the application is not limited to the specific embodiments.
Throughout the specification and claims, unless explicitly stated otherwise, the term "comprise" or variations thereof such as "comprises" or "comprising", etc. will be understood to include the stated element or component without excluding other elements or components.
In order to facilitate understanding of the technical solution of the present application, the following first explains in detail the technical terms that may occur in the present application.
backsingfile: the read-only qcow2 format back-end mirror file.
Snapshot: with respect to a fully available copy of a given data set, the copy includes an image of the corresponding data at some point in time (the point in time at which the copy began). The snapshot may be a copy of the data it represents, or may be a copy of the data.
External snapshot: the snapshots are stored in external separate files, and all the snapshots referred to herein are external snapshots.
bitmap: the dirty data which is also called dirty bitmap and can be added to the disk file in a certain period of time can be set with a mark, and the dirty data is a high-level function supported by qemu, and the bitmap is recorded in a memory. Disk formats supporting arbitrary formats, such as qcow2, raw, etc.
persistent dirty bitmap: the persistent bitmap is an improved version of the dirty bitmap, recorded on disk, and persistent dirty bitmap will not disappear when the virtual machine is turned off, persistent dirty bitmap is supported only when v2.10 starts.
drive-backup: the drive-backup is a real-time disk backup scheme provided by qemu, namely full-volume and incremental backup can be performed on a disk by using a snapshot chain of a qcow 2-format disk file and a bitmap associated with an external snapshot.
qemu: qemu is a set of analog processor software that distributes source code with GPL licenses, defaulting to support multiple architectures. The simulation system can simulate various architectures, is expandable, can customize a new instruction set, is open-source, is portable and has high simulation speed. The KVM acceleration can be used on an x86 framework supporting hardware virtualization and matched with a kernel ksm large page backup memory, the speed is stable and far exceeds VMware ESX, the simulation speed is increased, certain programs can be operated even in real time, linux programs can be operated on other platforms, operating states (such as operating programs) can be stored and restored, and a network card can be virtualized.
Virtual machine: refers to a complete computer system with complete hardware system functions that operates in a completely isolated environment through software simulation. Work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine in a computer, a part of hard disk and memory capacity of the physical machine are required to be used as the hard disk and memory capacity of the virtual machine. Each virtual machine has a separate CMOS, hard disk and operating system, and can operate as if it were a physical machine.
qcow2: is a mirrored format of qemu, is abbreviated as "qemu copy on write", and can be managed by qemu-img. qcow2 is a virtual block device, has a definition of a structure, and has functions of reducing storage space, snapshot, encryption and the like.
qemu-nbd: nbd refers to Network Block Device, as the name implies, which allows a user to access a piece of equipment, or an image of equipment, through the network. The qemu-nbd refers to that the block device or the file is mounted based on an nbd mode in the virtualized program qemu.
qemu-img: the disk mirror utility in the virtualizer qemu. qemu-img can create, view qcow2 mirror. In addition, snapshot making, mirror conversion and parent mirror supporting are supported.
Please refer to fig. 1, which illustrates an application scenario of the virtual machine backup method provided by the present application. In the implementation scenario shown in fig. 1, the terminal 101 that needs a data backup service and the data storage server 102 that has a virtual machine data backup function are included. Specifically, when the terminal 101 needs a data backup service, it may create a persistent bitmap with an external snapshot of the virtual machine currently in an active state or an original disk in an active state and perform a full-scale backup operation through the data storage server 102 based on a backup command. Further, based on the persistent bitmap, the backed-up dirty data is obtained, and incremental backup is performed on the virtual machine disk.
The virtual machine backup method of the embodiment of the application can be applied to the virtual machine backup system of the embodiment of the application. The virtual machine backup system can be configured at a terminal. Terminals may include, but are not limited to, PCs (Personal Computer, personal computers), PDAs (tablet computers), smartphones, smart wearable devices, and the like.
The terminal may establish a communication connection with each server through the network 103, and the network may be a wireless network or a wired network, which is not limited in this embodiment of the present application.
The data to be backed up may include, but is not limited to: file data (Word, excel, PPT, etc.), picture data (photographs, images, etc.), audio data (music, voice, etc.), video data (animations, videos, etc.), etc.
The data storage server 102 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), basic cloud computing services such as big data and artificial intelligence platforms, and the like.
Fig. 2 is a schematic flow chart of virtual machine backup according to an embodiment of the application. The virtual machine backup method specifically comprises the following steps:
s201: based on a backup command, creating a persistent bitmap by using an external snapshot of the virtual machine in an active state or an original disk in the active state;
it should be noted that, the external snapshot in the active state refers to a state of the last created external snapshot in the on state, and when a new snapshot is created again, the new snapshot is in the active state, and the external snapshot in the active state is lost. If the external snapshot does not exist, the original disk is considered to be in an active state.
It should be noted that, in the technical solution, a disk refers to a qcow2 file chain that includes a parent-child relationship and corresponds to all data of one disk of the virtual machine, and an original disk refers to a qcow2 file corresponding to the disk of the virtual machine.
S202: based on the variable base operation of qemu-img, carrying out full backup on the disk of the virtual machine in the shutdown state;
in an exemplary embodiment, the qemu-img-based variable base operation performs full backup on a disk of a virtual machine in a shutdown state, including: if the external snapshot exists, creating a backup file, and pointing a rear-end mirror image file of the backup file to the finally created external snapshot of the virtual machine; if no external snapshot exists currently, creating a backup file, and directing a rear-end mirror image file of the backup file to an original disk; and performing variable base operation on the backup file, and designating the back-end mirror file as an empty string.
For example, the backup file is backup qcow2, and the rear-end mirror file of the backup file is pointed to the external snapshot [ B ] in the active state based on a qemu-img command. And then, performing variable base operation on the backup file, and automatically merging the data in [ A ] [ B ] into the backup file when the backup file is designated as an empty string, so that the required full backup file is the [ backup.qcow2] after the variable base operation is completed.
S203: and based on the persistent bitmap and qemu-nbd operation, acquiring the backed-up dirty data, and performing incremental backup on the disk of the virtual machine.
It should be noted that, based on the persistent bitmap and qemu-nbd operations, obtaining the backed-up dirty data, and performing incremental backup on the disk of the virtual machine includes: if no new external snapshot is created after the last backup, acquiring the dirty data after the backup, and performing incremental backup on the virtual machine disk; and if a new external snapshot is created after the last backup, acquiring the backed-up dirty data, and performing incremental backup on the virtual machine disk.
In an exemplary embodiment, if a new external snapshot is not created after the last backup, obtaining the dirty data after the backup, and performing incremental backup on the virtual machine disk, including: if the external snapshot exists, acquiring dirty data in a last-created persistent bitmap bound with the external snapshot of the virtual machine as incremental backup data based on a qemu-nbd command; if the external snapshot does not exist, dirty data in the persistent bitmap bound with the original disk is obtained as incremental backup data; and writing the incremental backup data into the backup file.
It should be noted that, if no new external snapshot is created after the last backup, it is considered that all newly added data is recorded in the persistent bitmap in the form of dirty data after the last backup, if no external snapshot is created during the last backup, the persistent bitmap is bound to the original disk of the virtual machine, otherwise, the persistent bitmap is bound to the external snapshot created last based on the time point of the last backup. At this time, the incremental backup of the virtual machine disk only needs to acquire the dirty data recorded in the external snapshot or the original disk of the virtual machine after the backup, and write the dirty data into the backup file.
For example, the server uses qemu-nbd, the client uses libnbd to connect, uses the BlockStatus interface to obtain the status of each data block according to the specified size, screens and reads the dirty data, and then writes the dirty data into the incremental backup file [ backup.
In another exemplary embodiment, if a new external snapshot is 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 the external snapshot exists in the last backup, acquiring dirty data in a persistent bitmap bound based on the external snapshot of the virtual machine which is finally created in the last backup based on a qemu-nbd command and writing the dirty data into a backup file; if no external snapshot exists in the last backup, acquiring dirty data in the persistent bitmap bound with the original disk based on the qemu-nbd command and writing the dirty data into a backup file; and merging the data of the external snapshot created after the last backup with the backup file data through the variable base operation of qemu-img.
Specifically, the merging the data of the external snapshot created after the last backup with the backup file data through the qemu-img base-changing operation includes: newly creating a backup file, and pointing the rear-end mirror image file of the newly created backup file to an external snapshot created after the last backup through a base-changing operation; designating the back-end mirror file as a father snapshot of the external snapshot created after backup based on the base-changing operation, and merging the data of the external snapshot created after backup to the newly-built backup file; designating the back-end mirror image file as an original backup file based on the variable base operation; and designating the rear-end mirror image file as an empty character string based on the variable base operation, and merging the data of the original backup file into the newly-built backup file.
It should be noted that, since a plurality of external snapshots are created subsequently after the last backup, when each external snapshot is in an active state, dirty data formed by a data record newly added by the virtual machine disk is recorded on each external snapshot. If only the last external snapshot created is backed up during incremental backup, backup data is lost. If a new external snapshot is created after the previous backup, based on the qemu-nbd command, obtaining the dirty data of the persistent bitmap bound with the external snapshot created last based on the time point of the previous backup, writing the dirty data into the backup file, and merging the data of the external snapshot created after the previous backup with the backup file data through the base change operation of the qemu-img.
For example, if the last backup only created bitmap0 on [ A ] and then an external snapshot [ B ], the incremental data contains dirty data recorded on [ A ] and all data of [ B ] on the persistent bitmap. The original backup file is [ backup0.qcow2]. Firstly, a backup file [ backup.qcow2] is newly created, dirty data recorded by bitmap0 in [ A ] is obtained and written into the original backup file [ backup0.qcow2] according to the method in the previous exemplary embodiment. Then, the first time of the base, all data in [ B ] are merged into [ backup.qcow2], the second time of the base, the unsafe mode is used, only the backup of [ backup.qcow2] is pointed to [ backup0.qcow2] without data merging, the third time of the base, and the data of [ backup0.qcow2] are merged into [ backup.qcow2], thereby completing incremental backup [ backup.qcow2].
In another specific embodiment, if the previous backup only creates bitmap0 on [ a ], and then creates multiple external snapshots such as external snapshot [ B ], external snapshot [ C ] and the like sequentially, the incremental data includes dirty data recorded on bitmap0 bound by [ a ] and data in all external snapshots created after [ a ]. At this time, a newly added backup file [ backup. Qcow2] should be created first, and dirty data recorded by bitmap0 in [ a ] is obtained and written into the original backup file [ backup0.Qcow2] according to the above method. Then merging all data in the external snapshots of [ B ], [ C ] and the like into [ backup.qcow2] through a base changing operation; again, using the unsafe mode, only pointing the backingfile of [ backup.qcow2] to [ backup0.qcow2] without data merging; finally, based on the base change operation, the data of [ backup0.qcow2] is merged to [ backup0.qcow2] to complete the incremental backup.
It should be noted that the method further includes: based on a drive-backup command, creating a persistent bitmap for a virtual machine in an on-state by using an external snapshot of the virtual machine in an active state or an original disk in the active state at present and performing full backup for the disk; based on the qemu-nbd command, obtaining dirty data of the external snapshot bound persistent bitmap in the active state during the last backup and data of the external snapshot which is not in the active state and is created after the last backup, and writing the dirty data into a backup file; newly creating a backup file, acquiring data of an external snapshot in an active state at present based on a drive-backup command, writing the newly created backup file, and creating a persistent bitmap for the external snapshot in the active state at present; and merging the backup files into the newly-built backup files through the base changing operation, and completing incremental backup.
In the power-on state, the method for acquiring the dirty data of the external snapshot which is not in the active state can refer to the mode of the incremental backup in the power-off state, acquire the dirty data recorded by the bitmap by using qemu-nbd, and combine all the data of the snapshot which is not bound with the bitmap into the backup file [ backup.
And for the latest snapshot in the current active state, using a top mode of drive-backup full backup to backup. The acquired backup data is written to [ backup. Qcow2], and a persistent bitmap1 is created for the latest snapshot for the next incremental backup.
All the incremental data after the last backup can be obtained through the two steps, and then the obtained incremental data are combined into the final incremental backup, and the combining method is similar to the combining mode of the shutdown state incremental backup.
Referring to fig. 3, based on the same inventive concept as the aforementioned virtual machine backup method, an embodiment of the present application provides a virtual machine backup system 300, which includes a creation module 301, a full-scale backup module 302, and an incremental backup module 303.
Specifically, the creating module 301 is configured to create, based on a backup command, a persistent bitmap with an external snapshot of the virtual machine currently in an active state or an original disk in an active state; the full-volume backup module 302 is configured to perform full-volume backup on a disk of the virtual machine in a shutdown state based on a variable base operation of qemu-img; and the incremental backup module 303 is configured to obtain the backed-up dirty data based on the persistent bitmap and qemu-nbd operations, and perform incremental backup on the disk of the virtual machine.
It should be noted that, the full-volume backup module 302 is configured to perform full-volume backup on a disk of the virtual machine in a shutdown state based on a variable base operation of qemu-img, and includes: if the external snapshot exists, creating a backup file, and pointing a rear-end mirror image file of the backup file to the finally created external snapshot of the virtual machine; if no external snapshot exists currently, creating a backup file, and directing a rear-end mirror image file of the backup file to an original disk; and performing variable base operation on the backup file, and designating the back-end mirror file as an empty string.
The incremental backup module 303, configured to obtain the backed up dirty data based on the persistent bitmap, perform incremental backup on the virtual machine disk, and include: if no new external snapshot is created after the last backup and the external snapshot exists in the last backup, acquiring dirty data in a persistent bitmap bound with the last created external snapshot of the virtual machine as incremental backup data based on a qemu-nbd command; if no new external snapshot is created after the last backup and no external snapshot exists in the last backup, dirty data in the persistent bitmap bound with the original disk is obtained as incremental backup data; and writing the incremental backup data into the backup file. If a new external snapshot is created after the last backup and the external snapshot exists in the last backup, acquiring dirty data in a persistent bitmap bound based on the external snapshot of the virtual machine which is created last in the last backup based on a qemu-nbd command; if a new external snapshot is created after the last backup and no external snapshot exists in the last backup, acquiring dirty data in the persistent bitmap bound with the original disk based on a qemu-nbd command and writing the dirty data into a backup file; and merging the data of the external snapshot created after the last backup with the backup file data through the variable base operation of qemu-img.
It should be further noted that, the creating module 301 is further configured to create, for a virtual machine in an on state, a persistent bitmap for an external snapshot of the virtual machine in an active state or an original disk in an active state based on a drive-backup command; the full-back-up module 302 is further configured to perform full-back-up on a virtual machine disk in a power-on state; the incremental backup module 303 is further configured to obtain, for a virtual machine in a power-on state, dirty data of a persistent bitmap bound by an external snapshot in an active state when the virtual machine is backed up last time and data of an external snapshot created after the virtual machine is backed up last time, based on a qemu-nbd command; based on the drive-backup command, acquiring data of an external snapshot in the current active state and creating a persistent bitmap for the external snapshot in the current active state; and merging the dirty data of the persistent bitmap bound by the external snapshot in the active state during the last backup and the data of the external snapshot created after the last backup into the backup file through the base changing operation.
Referring to fig. 4, an embodiment of the present application further provides an electronic device 400, where the electronic device 400 includes at least one processor 401, a memory 402 (e.g., a nonvolatile memory), a memory 403, and a communication interface 404, and the at least one processor 401, the memory 402, the memory 403, and the communication interface 404 are connected together via a bus 405. The at least one processor 401 is operative to invoke the at least one program instruction stored or encoded in the memory 402 to cause the at least one processor 401 to perform the various operations and functions of the virtual machine backup method described in various embodiments of the present specification.
In embodiments of the present description, electronic device 400 may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile electronic devices, smart phones, tablet computers, cellular phones, personal Digital Assistants (PDAs), handsets, messaging devices, wearable electronic devices, consumer electronic devices, and the like.
Embodiments of the present application also provide a computer readable medium having computer-executable instructions carried thereon, where the computer-executable instructions, when executed by a processor, may be used to implement various operations and functions of the virtual machine backup method described in various embodiments of the present specification.
The computer readable medium in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, systems, and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing descriptions of specific exemplary embodiments of the present application are presented for purposes of illustration and description. It is not intended to limit the application to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain the specific principles of the application and its practical application to thereby enable one skilled in the art to make and utilize the application in various exemplary embodiments and with various modifications as are suited to the particular use contemplated. It is intended that the scope of the application be defined by the claims and their equivalents.
Claims (10)
1. A virtual machine backup method, comprising:
based on a backup command, creating a persistent bitmap by using an external snapshot of the virtual machine in an active state or an original disk in the active state;
based on the variable base operation of qemu-img, carrying out full backup on the disk of the virtual machine in the shutdown state;
and based on the persistent bitmap and qemu-nbd operation, acquiring the backed-up dirty data, and performing incremental backup on the disk of the virtual machine.
2. The virtual machine backup method as claimed in claim 1, wherein the qemu-img-based variable base operation performs full-scale backup on a disk of the virtual machine in a shutdown state, and the method comprises:
if the external snapshot exists, creating a backup file, and pointing a rear-end mirror image file of the backup file to the finally created external snapshot of the virtual machine;
if no external snapshot exists currently, creating a backup file, and directing a rear-end mirror image file of the backup file to an original disk;
and performing variable base operation on the backup file, and designating the back-end mirror file as an empty string.
3. The virtual machine backup method as claimed in claim 2, wherein the obtaining the backed up dirty data based on the persistent bitmap and qemu-nbd operations, and performing incremental backup on a disk of the virtual machine, includes:
if no new external snapshot is created after the last backup, acquiring the dirty data after the backup, and performing incremental backup on the virtual machine disk;
and if a new external snapshot is created after the last backup, acquiring the backed-up dirty data, and performing incremental backup on the virtual machine disk.
4. The virtual machine backup method as claimed in claim 3, wherein if no new external snapshot is created after the last backup, obtaining the backed-up dirty data, and performing incremental backup on the virtual machine disk, includes:
if the external snapshot exists, acquiring dirty data in a last-created persistent bitmap bound with the external snapshot of the virtual machine as incremental backup data based on a qemu-nbd command;
if the external snapshot does not exist, dirty data in the persistent bitmap bound with the original disk is obtained as incremental backup data;
and writing the incremental backup data into the backup file.
5. The virtual machine backup method as claimed in claim 3, wherein if a new external snapshot is created after the last backup, obtaining the backed up dirty data, and performing incremental backup on the virtual machine disk, includes:
if the external snapshot exists in the last backup, acquiring dirty data in a persistent bitmap bound based on the external snapshot of the virtual machine which is finally created in the last backup based on a qemu-nbd command and writing the dirty data into a backup file;
if no external snapshot exists in the last backup, acquiring dirty data in the persistent bitmap bound with the original disk based on the qemu-nbd command and writing the dirty data into a backup file;
and merging the data of the external snapshot created after the last backup with the backup file data through the variable base operation of qemu-img.
6. The virtual machine backup method as claimed in claim 5, wherein the merging the data of the external snapshot created after the last backup with the backup file data through the variant operation of qemu-img includes:
newly creating a backup file, and pointing the rear-end mirror image file of the newly created backup file to an external snapshot created after the last backup through a base-changing operation;
designating the back-end mirror file as a father snapshot of the external snapshot created after backup based on the base-changing operation, and merging the data of the external snapshot created after backup to the newly-built backup file;
designating the back-end mirror image file as an original backup file based on the variable base operation;
and designating the rear-end mirror image file as an empty character string based on the variable base operation, and merging the data of the original backup file into the newly-built backup file.
7. The virtual machine backup method of claim 1, wherein the method further comprises:
based on a drive-backup command, creating a persistent bitmap for a virtual machine in an on-state by using an external snapshot of the virtual machine in an active state or an original disk in the active state at present and performing full backup for the disk;
based on the qemu-nbd command, obtaining dirty data of the external snapshot bound persistent bitmap in the active state during the last backup and data of the external snapshot which is not in the active state and is created after the last backup, and writing the dirty data into a backup file;
newly creating a backup file, acquiring data of an external snapshot in an active state at present based on a drive-backup command, writing the newly created backup file, and creating a persistent bitmap for the external snapshot in the active state at present;
and merging the backup files into the newly-built backup files through the base changing operation, and completing incremental backup.
8. A virtual machine backup system, comprising:
the creation module is used for creating a persistent bitmap according to an external snapshot of the virtual machine in an active state or an original disk in the active state based on a backup command;
the full-volume backup module is used for carrying out full-volume backup on the virtual machine disk in the shutdown state based on the variable base operation of qemu-img;
and the incremental backup module is used for acquiring the backed-up dirty data based on the persistent bitmap and qemu-nbd operation and carrying out incremental backup on the disk of the virtual machine.
9. A computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the virtual machine backup method of any of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a computer to perform the virtual machine backup method of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310799500.5A CN116841799A (en) | 2023-06-30 | 2023-06-30 | Virtual machine backup method, system, equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310799500.5A CN116841799A (en) | 2023-06-30 | 2023-06-30 | Virtual machine backup method, system, equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116841799A true CN116841799A (en) | 2023-10-03 |
Family
ID=88159407
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310799500.5A Pending CN116841799A (en) | 2023-06-30 | 2023-06-30 | Virtual machine backup method, system, equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116841799A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117033085A (en) * | 2023-10-09 | 2023-11-10 | 武汉吧哒科技股份有限公司 | kvm virtual machine backup method and device, computer equipment and storage medium |
-
2023
- 2023-06-30 CN CN202310799500.5A patent/CN116841799A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117033085A (en) * | 2023-10-09 | 2023-11-10 | 武汉吧哒科技股份有限公司 | kvm virtual machine backup method and device, computer equipment and storage medium |
CN117033085B (en) * | 2023-10-09 | 2024-01-19 | 武汉吧哒科技股份有限公司 | kvm virtual machine backup method and device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9823877B2 (en) | Virtual machine backup from storage snapshot | |
US11042450B2 (en) | Mechanism for managing container runtime state | |
US8738883B2 (en) | Snapshot creation from block lists | |
JP6186374B2 (en) | System and method for secure migration to a virtualized platform | |
US9430332B1 (en) | Systems and methods for enabling efficient access to incremental backups | |
US8990164B1 (en) | Systems and methods for performing incremental backups | |
US10606646B1 (en) | Systems and methods for creating a data volume from within a software container and initializing the data volume with data | |
US9804878B2 (en) | Using a status indicator for a merge operation for writing data associated with a virtual machine | |
CN110704161B (en) | Virtual machine creation method and device and computer equipment | |
US11599385B2 (en) | System and method for distribution of dependent builds across orchestration job scheduler slaves | |
US8565545B1 (en) | Systems and methods for restoring images | |
CN116841799A (en) | Virtual machine backup method, system, equipment and readable storage medium | |
US9557980B2 (en) | Seamless application integration apparatus and method | |
US10169027B2 (en) | Upgrade of an operating system of a virtual machine | |
CN102662796B (en) | Method and system for recovering data | |
US9405709B1 (en) | Systems and methods for performing copy-on-write operations | |
US20180336085A1 (en) | Crash dump extraction of guest failure | |
US9110965B1 (en) | Systems and methods for disaster recovery from binary large objects | |
US11205019B2 (en) | Multiple computing environments on a computer system | |
US9886298B2 (en) | Detecting an interrupted operation associated with a virtual machine | |
CN104717175A (en) | Virtual desktop processing method and system | |
CN114168263A (en) | Method and application for live migration of virtual machines among multiple clusters of cloud platform | |
CN114238934A (en) | Equipment information acquisition method, device, equipment and medium | |
US9836515B1 (en) | Systems and methods for adding active volumes to existing replication configurations | |
US20140075092A1 (en) | Simulating eeprom in virtual distributed switches |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |