Data recovery method, data backup method, data recovery device, data backup device and computer equipment of virtual machine

By creating a new virtual machine with the same configuration and uploading mirror files in the snapshot chain in the backup metadata, the problem of data loss of virtual machine data is solved, and the rapid recovery and high reliability of the data are realized.

CN119356945AActive Publication Date: 2025-01-24GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411480599.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-01-24
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

During operation, virtual machines are prone to failure due to various reasons, resulting in data loss. It is difficult for the prior art to effectively avoid such data loss.

Method used

Provides a virtual machine data recovery method by creating a new virtual machine with the same configuration as the target virtual machine, and using the snapshot chain in the backup metadata to upload image files in sequence to restore data.

Benefits of technology

It achieves rapid data recovery when a virtual machine fails, avoids data loss, and ensures data integrity and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356945A_ABST
    Figure CN119356945A_ABST
Patent Text Reader

Abstract

The invention relates to a data recovery method, a data backup method, a data recovery device, a data backup device, computer equipment, a computer readable storage medium and a computer program product of a virtual machine, and relates to the technical field of computers. The method comprises the following steps: in response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; obtaining a first snapshot chain in backup metadata of the first virtual machine; and on the basis of the first snapshot chain, uploading the mirror image files corresponding to the first snapshot chain to the second virtual machine in sequence, and obtaining second snapshots in one-to-one correspondence with the first snapshots and a second snapshot chain composed of the second snapshots so as to complete data recovery of the first virtual machine. By adopting the method, the data recovery of the virtual machine can be realized, and the data loss of the virtual machine is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data recovery method, a data backup method, a data recovery device, a data backup device, a computer device, a computer-readable storage medium, and a computer program product for a virtual machine. Background Art

[0002] A virtual machine is a computer system with complete hardware functions that runs in an isolated environment using virtualization technology. A virtual machine can run multiple operating systems simultaneously on a physical machine. These operating systems are independent of each other and do not interfere with each other, thereby improving the utilization of hardware resources.

[0003] However, virtual machines may fail during operation due to various reasons, resulting in data loss of the virtual machines. Summary of the invention

[0004] Based on this, it is necessary to provide a data recovery method, data backup method, data recovery device, data backup device, computer equipment, computer-readable storage medium and computer program product for a virtual machine that can avoid data loss of the virtual machine in response to the above technical problems.

[0005] In a first aspect, the present application provides a method for recovering data of a virtual machine, comprising:

[0006] In response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding one to one to the respective first disks;

[0007] Obtaining a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot;

[0008] Based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence to obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

[0009] In one of the embodiments, each image file has a corresponding pre-order image file attribute, and the pre-order image file attribute is used to record the file identifier of the previous image file of the disk to which the image file belongs; each second disk has corresponding image file index information, and the image file index information is used to record the file identifier of an uploaded image file on the second disk, and the image file index information is initialized to empty;

[0010] The method of uploading the image files corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain to obtain second snapshots corresponding to the first snapshots and a second snapshot chain composed of the second snapshots includes:

[0011] traversing each first snapshot in the first snapshot chain in sequence, and for each traversed first snapshot, creating a second blank snapshot corresponding to the first snapshot in the second virtual machine, and determining, among the second disks, a second target disk corresponding to the first associated disk of the first snapshot; the first snapshots are sorted in the first snapshot chain in chronological order according to their respective creation times;

[0012] Based on the modification of the preceding image file attribute of the image file under the first snapshot and the modification of the image file index information of the second target disk, the image file under the first snapshot is uploaded to the second virtual machine as the image file of the second target disk under the second blank snapshot, so as to obtain a second snapshot corresponding to the first snapshot;

[0013] A second snapshot chain of the second virtual machine is obtained according to the second snapshots that correspond one-to-one between the second virtual machine and the first snapshots.

[0014] In one embodiment, based on modifying the preceding image file attribute of the image file under the first snapshot and modifying the image file index information of the second target disk, uploading the image file under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine to obtain a second snapshot corresponding to the first snapshot includes:

[0015] Traversing each first associated disk of the first snapshot, and for each traversed first associated disk, acquiring image file index information of a second target disk corresponding to the first associated disk;

[0016] When the image file index information is empty, uploading the image file of the first associated disk under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modifying the image file index information to the file identifier of the image file;

[0017] In the case where the image file index information is not empty, modifying the pre-order image file attribute of the image file of the first associated disk under the first snapshot to the image file index information to obtain a modified image file, uploading the modified image file to the second virtual machine as the image file of the second target disk under the second blank snapshot, and modifying the image file index information to the file identifier of the modified image file;

[0018] Based on the image file of the second target disk of each first associated disk under the second blank snapshot, a second snapshot of the second virtual machine corresponding to the first snapshot is obtained.

[0019] In one of the embodiments, the preceding image file attributes of the image file are recorded in the image file;

[0020] The modification of the preceding image file attribute of the image file under the first snapshot is achieved by the following process:

[0021] Reading a preset field of the image file; the preset field records an offset value of a preceding image file attribute of the image file in the image file;

[0022] Verifying the preset field;

[0023] In the case where the preset field is verified, reading the offset value in the preset field;

[0024] Based on the offset value, the preceding image file attribute of the image file is read, and the preceding image file attribute of the image file is modified.

[0025] In one of the embodiments, the backup metadata of the first virtual machine also includes configuration information of the first virtual machine and backup locations of each image file corresponding to the first snapshot chain;

[0026] The creating a second virtual machine having the same configuration as the first virtual machine includes:

[0027] Creating, based on the configuration information in the backup metadata of the first virtual machine, the second virtual machine having the same configuration as the first virtual machine;

[0028] Before uploading the image files corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain to obtain second snapshots corresponding to the first snapshots and a second snapshot chain composed of the second snapshots, the method further includes:

[0029] Based on the backup locations of the image files corresponding to the first snapshot chain in the backup metadata of the first virtual machine, the image files corresponding to the first snapshot chain are obtained.

[0030] In a second aspect, the present application also provides a data backup method for a virtual machine, comprising:

[0031] In response to a data backup request for a first virtual machine, obtaining each first snapshot currently existing in the first virtual machine; a plurality of first disks are configured in the first virtual machine; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creating the first snapshot;

[0032] Determine, according to the first snapshots, a first snapshot chain of the first virtual machine under the current data backup; the first snapshot chain is composed of the first snapshots, and the first snapshots are arranged in the first snapshot chain in chronological order according to their respective creation times;

[0033] Traversing each first snapshot in the first snapshot chain in sequence, backing up the image file under each traversed first snapshot, and recording the backup location of the image file;

[0034] When traversal of all first snapshots in the first snapshot chain is completed, the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine are determined as backup metadata of the first virtual machine under the current data backup, and the backup metadata is saved; the backup metadata is used to implement a data recovery method for a virtual machine.

[0035] In one embodiment, determining, according to the first snapshots, a first snapshot chain of the first virtual machine under the current data backup includes:

[0036] In the case where the backup request is an incremental backup request, based on the backup metadata of the first virtual machine under the historical data backup, determining a first snapshot chain of the first virtual machine under the historical data backup, and determining each first snapshot in the first snapshot chain of the first virtual machine under the historical data backup as each first historical snapshot of the first virtual machine;

[0037] Determine, among the first snapshots currently existing in the first virtual machine, the first snapshots other than the first historical snapshots as first current snapshots;

[0038] According to the first current snapshots and the first snapshot chain of the first virtual machine under the historical data backup, a first snapshot chain of the first virtual machine under the current data backup is obtained.

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

[0040] In response to a snapshot request for at least one first disk in the first virtual machine, determining the first disk targeted by the snapshot request as a first associated disk of a first snapshot to be created;

[0041] A snapshot operation is performed on the first associated disk, and an image file of the first associated disk at the current moment is generated as the image file of the first associated disk under the first snapshot to be created, thereby obtaining a first snapshot of the first associated disk at the current moment; the current moment is the moment when the first snapshot is created.

[0042] In a third aspect, the present application further provides a data recovery device for a virtual machine, comprising:

[0043] A virtual machine creation module, configured to create a second virtual machine with the same configuration as the first virtual machine in response to a data recovery request for the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding to the respective first disks one by one;

[0044] A snapshot chain acquisition module, used to acquire a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot;

[0045] A data recovery processing module is used to upload each image file corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain, obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

[0046] In a fourth aspect, the present application further provides a virtual machine backup device, comprising:

[0047] A first snapshot acquisition module is used to obtain each first snapshot currently existing in the first virtual machine in response to a data backup request for the first virtual machine; the first virtual machine is configured with multiple first disks; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creating the first snapshot;

[0048] a snapshot chain determination module, configured to sequentially traverse each first snapshot in the first snapshot chain, back up the image file under each traversed first snapshot, and record the backup location of the image file;

[0049] an image file backup module, configured to traverse the first snapshots in the first snapshot chain in sequence, back up the image file under each traversed first snapshot, and record the backup location of the image file;

[0050] A backup data saving module is used to determine the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine as the backup metadata of the first virtual machine under the current data backup when the traversal of each first snapshot in the first snapshot chain is completed, and save the backup metadata; the backup metadata is used to implement a data recovery method for a virtual machine.

[0051] In a fifth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0052] In response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding one to one to the respective first disks;

[0053] Obtaining a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot;

[0054] Based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence to obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

[0055] In a sixth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0056] In response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding one to one to the respective first disks;

[0057] Obtaining a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot;

[0058] Based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence to obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

[0059] In a seventh aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0060] In response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding one to one to the respective first disks;

[0061] Obtaining a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot;

[0062] Based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence to obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

[0063] The data recovery method, data backup method, data recovery device, backup device, computer equipment, computer-readable storage medium and computer program product of the virtual machine are as follows: first, in response to a data recovery request for a first virtual machine, a second virtual machine with the same configuration as the first virtual machine is created; the first virtual machine is configured with multiple first disks, and the second virtual machine is configured with each second disk corresponding to each first disk; then, a first snapshot chain in the backup metadata of the first virtual machine is obtained; the first snapshot chain is composed of multiple first snapshots; each first snapshot corresponds to at least one first associated disk and the image file of each first associated disk at the creation time of the first snapshot; finally, based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence, and each second snapshot corresponding to each first snapshot and a second snapshot chain composed of each second snapshot are obtained to complete the data recovery of the first virtual machine. In this way, based on the first snapshot chain in the backup metadata of the first virtual machine, the image files of each first disk in the first virtual machine under each first snapshot can be uploaded to the second virtual machine in sequence, and each second snapshot of the second virtual machine is obtained, and the second snapshot chain of the second virtual machine is further formed, so as to realize the data recovery of the first virtual machine in the second virtual machine with the same configuration as the first virtual machine. Based on the above process, data recovery of the virtual machine can be achieved to avoid data loss of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0065] FIG1 is a schematic diagram of a flow chart of a method for recovering data of a virtual machine in one embodiment;

[0066] FIG2 is a flow chart of steps for obtaining a second snapshot chain of a second virtual machine based on a first snapshot chain in one embodiment;

[0067] 3 is a flowchart of steps for uploading the image file under the first snapshot to the second virtual machine to obtain the second snapshot based on the preceding image file attributes of the image file under the first snapshot and the image file index information of the second target disk in one embodiment;

[0068] FIG4 is a flowchart of steps for modifying the attributes of a preceding image file of an image file under a first snapshot in one embodiment;

[0069] FIG5 is a schematic diagram of a flow chart of a method for backing up data of a virtual machine in one embodiment;

[0070] 6 is a flowchart of steps for determining a first snapshot chain of a first virtual machine under current data backup according to each first snapshot in one embodiment;

[0071] FIG7 is a schematic diagram of a flow chart of a method for data backup and data recovery of a virtual machine in one embodiment;

[0072] FIG8 is a schematic diagram of a backup process in one embodiment;

[0073] FIG9 is a schematic diagram of a recovery process in one embodiment;

[0074] FIG10 is a schematic diagram of a modification process in one embodiment;

[0075] FIG11 is a structural block diagram of a data recovery device for a virtual machine in one embodiment;

[0076] FIG12 is a block diagram of a data backup device for a virtual machine in one embodiment;

[0077] FIG. 13 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0079] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0080] In one embodiment, as shown in FIG1 , a data recovery method for a virtual machine is provided. This embodiment uses the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a server and a terminal, and is implemented through the interaction between the server and the terminal; wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; the terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, etc. In this embodiment, the method includes the following steps:

[0081] Step S102: In response to a data recovery request for a first virtual machine, create a second virtual machine with the same configuration as the first virtual machine.

[0082] The first virtual machine is a virtual machine to be restored. In a specific application, the virtual machine can be a virtual machine based on any virtual machine system. Preferably, the virtual machine is an ovirt virtual machine based on the ovirt system (Open Virtualization Manager, an open source virtualization software).

[0083] In the present application, data recovery for the first virtual machine is a heterogeneous machine recovery.

[0084] The first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with second disks corresponding to the first disks one by one. Furthermore, each second disk has the same configuration as the first disk corresponding to it.

[0085] The data recovery of the first virtual machine is performed in the second virtual machine.

[0086] Specifically, in response to a user's data recovery request for a certain virtual machine, the server determines the virtual machine targeted by the data recovery request as a first virtual machine to be recovered, and creates a second virtual machine with the same configuration as the first virtual machine based on the backup metadata of the first virtual machine.

[0087] For example, the server first creates a second virtual machine with the same specifications as the first virtual machine and is blank; then, the server creates disks in the second virtual machine with the same configuration as the first disks in the first virtual machine, obtains second disks corresponding one-to-one to the first disks, and then obtains a second virtual machine with the same configuration as the first virtual machine.

[0088] Step S104: obtaining a first snapshot chain in the backup metadata of the first virtual machine.

[0089] The snapshot chain of the virtual machine is used to represent the dependency relationship between multiple snapshots of the virtual machine. In a specific application, each snapshot forms a snapshot chain based on the order of their creation time.

[0090] The backup metadata of the first virtual machine refers to the virtual machine data obtained when backing up the first virtual machine; the backup metadata of the first virtual machine at least includes the first snapshot chain of the first virtual machine. In a specific application, the backup metadata of the first virtual machine can be stored in the first virtual machine or outside the first virtual machine.

[0091] The first snapshot chain is composed of multiple first snapshots of the first virtual machine.

[0092] Each first snapshot has at least one first associated disk among the multiple first disks; each first snapshot is obtained by taking a snapshot of each first associated disk of the first snapshot; and each first snapshot has an image file of each first associated disk of the first snapshot at the time of creating the first snapshot.

[0093] That is, in the present application, each snapshot corresponds to at least one disk and an image file of the corresponding disk under the snapshot.

[0094] In actual applications, if the virtual machine is an ovirt virtual machine, the image file is a qcow2 (a file format) file, and the snapshot is an inactive snapshot, that is, the snapshot_type attribute of the snapshot is not active; in an ovirt virtual machine, in addition to inactive snapshots, there are also active snapshots, that is, the snapshot_type attribute of the snapshot is active. The active snapshot is created when the disk is created, which is equivalent to an activity log. The data in it is changeable and is used to reflect the data modification of the corresponding disk.

[0095] Taking the ovirt virtual machine as an example, each snapshot has a VM_Id attribute and a disks attribute. The VM_Id attribute records the virtual machine ID of the virtual machine to which the snapshot belongs. The disks attribute is a two-dimensional array. The first dimension records the disk ID of the disk corresponding to the snapshot, and the second dimension records the file ID of the image file of the disk under the snapshot. For example, for a virtual machine VM1 configured with disk D1, disk D2, and disk D3, the server takes a snapshot of disk D1 and disk D2 at a certain moment, and obtains a snapshot snapshot1. The image file of disk D1 at this moment is qcow2_D1, and the image file of disk D2 at this moment is qcow2_D2. Then, the VM_Id attribute of snapshot snapshot1 is VM1; the elements of the disks attribute of snapshot snapshot1 in the first dimension are D1 and D2, the elements of the second dimension under element D1 are qcow2_D1, and the elements of the second dimension under element D2 are qcow2_D2.

[0096] Specifically, the server obtains backup metadata of the first virtual machine, and obtains a first snapshot chain in the backup metadata, where the first snapshot chain describes a dependency relationship between first snapshots of the first virtual machine under the data backup corresponding to the backup metadata.

[0097] Step S106, based on the first snapshot chain, upload each image file corresponding to the first snapshot chain to the second virtual machine in sequence, obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of each second snapshot, so as to complete the data recovery of the first virtual machine.

[0098] The image files corresponding to the first snapshot chain refer to the image files of each first associated disk of each first snapshot in the first snapshot chain at the creation time of the corresponding first snapshot.

[0099] Specifically, based on the dependency relationship between each first snapshot represented by the first snapshot chain, the server uploads the image file under each first snapshot as the image file of the second disk corresponding to the first associated disk of the first snapshot at the creation time of the first snapshot to the second virtual machine, thereby obtaining each image file of each second disk and further obtaining each second snapshot and second snapshot chain; wherein, each second disk corresponds to each image file at the same creation time, forming a second snapshot corresponding to the first snapshot at the creation time; each second snapshot forms a second snapshot chain in the order of the creation time of the first snapshot to which it corresponds. Based on the above process, the server obtains each second snapshot corresponding to each first snapshot one by one by uploading each image file to the second virtual machine, and further obtains the second snapshot chain corresponding to the first snapshot chain. Since the first snapshot chain represents the dependency relationship between each first snapshot of the second virtual machine, the second virtual machine with the second snapshot chain completes the data recovery of the first virtual machine.

[0100] It is easy to understand that, since each second snapshot corresponds to each first snapshot one-to-one, similar to the first snapshot, each second snapshot has at least one second associated disk in the multiple second disks, and each first snapshot has an image file of each second associated disk of the first snapshot at the creation time of the first snapshot corresponding to the second snapshot.

[0101] In the above-mentioned data recovery method for a virtual machine, first, in response to a data recovery request for a first virtual machine, a server creates a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with multiple first disks, and the second virtual machine is configured with each second disk corresponding to each first disk; then, the server obtains a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of multiple first snapshots; each first snapshot corresponds to at least one first associated disk and the image file of each first associated disk at the creation time of the first snapshot; finally, based on the first snapshot chain, the server uploads each image file corresponding to the first snapshot chain to the second virtual machine in sequence, obtains each second snapshot corresponding to each first snapshot and a second snapshot chain composed of each second snapshot, so as to complete the data recovery of the first virtual machine. In this way, based on the first snapshot chain in the backup metadata of the first virtual machine, the server can upload the image files of each first disk in the first virtual machine under each first snapshot in sequence to the second virtual machine, obtain each second snapshot of the second virtual machine, and further form a second snapshot chain of the second virtual machine, so as to realize the data recovery of the first virtual machine in the second virtual machine with the same configuration as the first virtual machine. Based on the above process, the data recovery of the virtual machine can be realized, and the data loss of the virtual machine can be avoided.

[0102] In an exemplary embodiment, each image file has a corresponding preceding image file attribute, and the preceding image file attribute is used to record the file identifier of the previous image file of the disk to which the image file belongs.

[0103] The "previous image file" refers to the previous image file of the disk in chronological order.

[0104] In actual applications, if the virtual machine is an ovirt virtual machine, the attribute of the preceding image file is the backing file attribute of the qcow2 file, and is recorded in the backing file field of the qcow2 file.

[0105] It is easy to understand that if the image file is the first in the time sequence (that is, the earliest image file on the disk), then the preceding image file attribute of the image file is empty.

[0106] Each second disk has corresponding image file index information, and the image file index information is used to record the file identifier of an uploaded image file on the second disk, and the image file index information is initialized to be empty.

[0107] The image file index information of each second disk is initialized when the second disk is created.

[0108] As shown in FIG. 2 , the above step S106, based on the first snapshot chain, sequentially uploading each image file corresponding to the first snapshot chain to the second virtual machine, obtaining each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, specifically includes the following steps:

[0109] Step S202, traverse each first snapshot in the first snapshot chain in turn, create a second blank snapshot corresponding to the first snapshot in the second virtual machine for each traversed first snapshot, and, in each second disk, determine a second target disk corresponding to the first associated disk of the first snapshot.

[0110] Step S204, based on the modification of the preceding image file attributes of the image file under the first snapshot and the modification of the image file index information of the second target disk, the image file under the first snapshot is uploaded to the second virtual machine as the image file of the second target disk under the second blank snapshot, to obtain a second snapshot corresponding to the first snapshot.

[0111] Step S206: obtaining a second snapshot chain of the second virtual machine according to each second snapshot that corresponds one-to-one to each first snapshot of the second virtual machine.

[0112] The first snapshots are arranged in the first snapshot chain in chronological order according to their creation times.

[0113] The second target disk is a second disk corresponding to the first associated disk of the first snapshot among the second disks.

[0114] Specifically, when the server configures each second disk for the second virtual machine, it initializes the corresponding image file index information for each second disk to be empty.

[0115] The server traverses each first snapshot according to the sorting order of each first snapshot in the first snapshot chain, starting from the first first snapshot (that is, the first snapshot with the earliest creation time).

[0116] For the first snapshot traversed, the server first creates a second blank snapshot corresponding to the first snapshot in the second virtual machine, and for each first associated disk of the first snapshot, determines the second disk corresponding to the first associated disk in each second disk, and obtains each second target disk; then, the server uploads each image file under the first snapshot to the second virtual machine as the image file under the second blank snapshot corresponding to the first snapshot, and obtains the second snapshot corresponding to the first snapshot. At the same time, since the pre-order image file attribute of the image file records the file identifier of the previous image file of the disk to which the image file belongs, and the image file index information of the second disk records the file identifier of the last uploaded image file on the second disk, therefore, in the process of uploading the image file, the server also needs to modify the pre-order image file attribute of the image file and the image file index information of the second target disk accordingly, so as to ensure that for each second disk, the time sequence relationship of each image file is consistent with the time sequence relationship of each image file of the first disk corresponding to the second disk, and, for the second virtual machine, the time sequence relationship of each second snapshot is consistent with the time sequence relationship of each first snapshot of the first virtual machine.

[0117] After traversing the first snapshots of the first snapshot chain, the server obtains the second snapshots of the second virtual machine corresponding to the first snapshots one by one, and then obtains a second snapshot chain of the second virtual machine consisting of the second snapshots.

[0118] In this embodiment, the server can ensure that, for each second disk, the timing relationship of each image file is consistent with the timing relationship of each image file of the first disk corresponding to the second disk by modifying the preceding image file attribute of the image file and the image file index information of the second target disk, and that, for the second virtual machine, the timing relationship of each second snapshot is consistent with the timing relationship of each first snapshot of the first virtual machine, thereby obtaining each second snapshot corresponding to each first snapshot and a second snapshot chain corresponding to the first snapshot chain, thereby completing the data recovery of the first virtual machine and ensuring the correctness of the data recovery of the first virtual machine.

[0119] In an exemplary embodiment, as shown in FIG. 3 , the above step S204, based on the modification of the preceding image file attribute of the image file under the first snapshot and the modification of the image file index information of the second target disk, uploads the image file under the first snapshot to the second virtual machine as the image file under the second blank snapshot of the second target disk, and obtains a second snapshot corresponding to the first snapshot, specifically including the following steps:

[0120] Step S302: traverse each first associated disk of the first snapshot, and for each traversed first associated disk, obtain image file index information of a second target disk corresponding to the first associated disk.

[0121] Step S304, when the image file index information is empty, upload the image file of the first associated disk under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modify the image file index information to the file identifier of the image file.

[0122] Or,

[0123] Step S306, when the image file index information is not empty, modify the preceding image file attribute of the image file of the first associated disk under the first snapshot to the image file index information, obtain the modified image file, upload the modified image file to the second virtual machine as the image file of the second target disk under the second blank snapshot, and modify the image file index information to the file identifier of the modified image file.

[0124] Step S308: obtaining a second snapshot of the second virtual machine corresponding to the first snapshot based on the image file of the second target disk of each first associated disk under the second blank snapshot.

[0125] Specifically, the server traverses each first associated disk of the first snapshot.

[0126] For each first associated disk traversed, the server first obtains the image file index information of the second target disk corresponding to the first associated disk, and determines whether the image file index information of the second target disk is empty.

[0127] If the image file index information of the second target disk is empty, it means that the second target disk has not uploaded any image file at present, that is, for the second target disk, the image file to be uploaded is the first image file of the second target disk in the time sequence. Therefore, the server directly uploads the image file of the first associated disk under the first snapshot being traversed as the image file of the second target disk under the second blank snapshot corresponding to the first snapshot being traversed to the second virtual machine, and modifies the image file index information of the second target disk to the file identifier of the image file.

[0128] If the image file index information of the second target disk is not empty, it means that the second target disk has currently uploaded an image file, that is, for the second target disk, the image file to be uploaded has a previous image file in the time sequence, and the file identifier of the previous image file is recorded in the image file index information of the second target disk. Therefore, the server first modifies the pre-order image file attribute of the image file of the first associated disk being traversed under the first snapshot being traversed to the image file index information of the second target disk, so as to establish the time sequence relationship between the image file to be uploaded and the previous image file of the second target disk, and obtain the modified image file, and then upload the modified image file as the image file of the second target disk under the second blank snapshot corresponding to the first snapshot being traversed to the second virtual machine, and modify the image file index information of the second target disk to the file identifier of the uploaded image file, so as to ensure that the time sequence relationship between the image files constructed when uploading the image files later is correct.

[0129] After traversing each first associated disk of the first snapshot being traversed, the server obtains a second snapshot of the second virtual machine corresponding to the first snapshot based on the image file of the second target disk of each first associated disk under the second blank snapshot.

[0130] In this embodiment, the server can ensure that, for each second disk, the timing relationship of each image file is consistent with the timing relationship of each image file of the first disk corresponding to the second disk by modifying the preceding image file attribute of the image file and the image file index information of the second target disk, and that, for the second virtual machine, the timing relationship of each second snapshot is consistent with the timing relationship of each first snapshot of the first virtual machine, so that each second snapshot corresponding to each first snapshot can be obtained, thereby ensuring the correctness of data recovery of the first virtual machine.

[0131] In an exemplary embodiment, the preceding image file attributes of the image file are recorded in the image file.

[0132] In actual applications, if the virtual machine is an ovirt virtual machine, the attribute of the preceding image file is the backing file attribute of the qcow2 file, and is recorded in the backing file field of the qcow2 file.

[0133] As shown in FIG. 4 , in the above step S204, the modification of the attributes of the preceding image file of the image file under the first snapshot is implemented by the following steps:

[0134] Step S402, reading a preset field of the image file.

[0135] Step S404: verify the preset fields.

[0136] Step S406: when the preset field is verified, read the offset value in the preset field.

[0137] Step S408: Based on the offset value, read the preceding image file attribute of the image file, and modify the preceding image file attribute of the image file.

[0138] The preset field records the offset value of the preceding image file attribute of the image file in the image file.

[0139] Specifically, the server reads a preset field of the image file and performs a validity check on the preset field. If the validity check of the preset field passes, the server further reads an offset value in the preset field. The offset value is used to point to the field where the preceding image file attribute of the image file is located in the image file. Therefore, the server reads the preceding image file attribute of the image file based on the offset value and modifies the preceding image file attribute of the image file.

[0140] In actual applications, if the virtual machine is an ovirt virtual machine, the preset field is the first twenty bytes of the qcow2 file.

[0141] Taking the qcow2 file as an example, the first four bytes of the first twenty bytes are the format identification field (magic), which is of type uint32 and is used to identify the file as a file in the qcow2 format.

[0142] The next four bytes are the version identification field (version), which is of type uint32 and is used to identify the qcow2 version of the file.

[0143] The next eight bytes are the offset value field (backing file offset), which is of uint64 type and is used to identify the offset value of the backing file attribute of the previous image file in the qcow2 file.

[0144] The last four bytes are the length field (backing file size), which is of type uint32 and is used to identify the length of the backing file attribute.

[0145] Specifically, the server opens the qcow2 file in read-write mode, reads the first twenty bytes, and parses each field (format identification field, version identification field, offset value field, and length field) in big-endian order.

[0146] Then, the server verifies the validity of the format identification field, version identification field, and length field respectively. The validity of the format identification field refers to whether the file format identified by the format identification field is the qcow2 format; the validity of the version identification field refers to whether the version number identified by the version identification field is the version currently supported by the qcow2 format; the validity of the length field refers to whether the length identified by the length field is equal to the length of the file identification of the qcow2 file.

[0147] Next, when the format identification field, version identification field, and length field all pass the legitimacy check, the server starts reading the field corresponding to the length identified by the length field from the offset value corresponding to the offset value field of the qcow2 file. The value of this field is the backing file attribute, and the server overwrites the backing file attribute to implement the modification.

[0148] If any one of the format identification field, version identification field, and length field fails to pass the validity check, the server reports an error and ends.

[0149] In this embodiment, the server fully utilizes the characteristics of the data structure of the image file, and can obtain the offset value of the attribute of the preceding image file from the preset field by reading and verifying the legality of the preset field, thereby realizing the reading and modification of the attribute of the preceding image file. Taking the qcow2 file as an example, currently, the backing file attribute of the qcow2 file is usually modified with the help of a third-party tool. However, based on this embodiment, the server can fully utilize the composition of the first twenty bytes of the qcow2 file without the help of a third-party tool, and the characteristics that the length of the backing file attribute is the same as the length of the file identifier of the image file, and can quickly and directly locate and modify the backing file attribute without affecting other contents of the qcow2 file.

[0150] In an exemplary embodiment, the backup metadata of the first virtual machine also includes configuration information of the first virtual machine and backup locations of each image file corresponding to the first snapshot chain.

[0151] In the above step S102, creating a second virtual machine with the same configuration as the first virtual machine specifically includes the following contents: creating a second virtual machine with the same configuration as the first virtual machine based on the configuration information in the backup metadata of the first virtual machine.

[0152] In the above step S106, based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence, and before each second snapshot corresponding to each first snapshot and a second snapshot chain composed of each second snapshot is obtained, the following specific content is also specifically included: based on the backup location of each image file corresponding to the first snapshot chain in the backup metadata of the first virtual machine, each image file corresponding to the first snapshot chain is obtained.

[0153] Specifically, the server creates a second virtual machine with the same configuration as the first virtual machine based on the configuration information in the backup metadata; and obtains each image file corresponding to the first snapshot chain based on the backup location in the backup metadata.

[0154] In this embodiment, the server can create a second virtual machine that meets the conditions by backing up the metadata, and can obtain various image files used to implement data recovery for the first virtual machine.

[0155] Based on the same inventive concept, as shown in FIG5 , in an exemplary embodiment, the present application also provides a data backup method for a virtual machine. This embodiment uses the method applied to a server as an example. It can be understood that the method can also be applied to a terminal, and can also be applied to a system including a server and a terminal, and is implemented through the interaction between the server and the terminal; wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; the terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, etc. In this embodiment, the method includes the following steps:

[0156] Step S502: In response to a data backup request for a first virtual machine, obtain each currently existing first snapshot of the first virtual machine.

[0157] Among them, multiple first disks are configured in the first virtual machine; each first snapshot has at least one first associated disk in the multiple first disks; each first snapshot is obtained by taking a snapshot of each first associated disk of the first snapshot; and each first snapshot has an image file of each first associated disk of the first snapshot at the time of creating the first snapshot.

[0158] Specifically, in response to a user's data backup request for a certain virtual machine, the server determines the virtual machine targeted by the data backup request as a first virtual machine to be backed up, and obtains each first snapshot currently existing in the first virtual machine.

[0159] Step S504: determining a first snapshot chain of the first virtual machine under the current data backup according to each first snapshot.

[0160] The first snapshot chain is composed of various first snapshots, and the various first snapshots are arranged in the first snapshot chain in chronological order according to their respective creation times.

[0161] Specifically, the server composes a first snapshot chain of the first virtual machine under the current data backup according to the chronological order of creation times of the first snapshots.

[0162] Step S506: traverse the first snapshots in the first snapshot chain in sequence, back up the image file under each traversed first snapshot, and record the backup location of the image file.

[0163] Specifically, the server traverses each first snapshot according to the sorting order of each first snapshot in the first snapshot chain, starting from the first first snapshot (that is, the first snapshot with the earliest creation time).

[0164] For the traversed first snapshot, the server determines each first associated disk corresponding to the first snapshot, and traverses each first associated disk.

[0165] For the first associated disk that is traversed, the server obtains the image file of the first associated disk under the first snapshot being traversed, backs up the image file, and records the backup location of the image file.

[0166] After the server has traversed all the first associated disks of the first snapshot being traversed, it starts to traverse the next first snapshot until all the first snapshots are traversed, thus completing the traversal of all the first snapshots.

[0167] Step S508, when the traversal of each first snapshot in the first snapshot chain is completed, the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine are determined as the backup metadata of the first virtual machine under the current data backup, and the backup metadata is saved.

[0168] The backup metadata is used to implement the data recovery method of the virtual machine in any one of the above embodiments of the present application.

[0169] Specifically, after traversing each first snapshot of the first snapshot chain, the server completes the backup of the image files currently existing in the first virtual machine, and determines the first snapshot chain, the backup locations of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine as the backup metadata of the first virtual machine under the current backup, and then saves the backup metadata; subsequently, through the backup metadata, the server can realize data recovery for the first virtual machine.

[0170] It should be noted that the specific limitations of the data backup method for a virtual machine provided in this embodiment can refer to the limitations of the data recovery method for a virtual machine in the above text, and will not be repeated here.

[0171] In the above-mentioned data backup method for a virtual machine, first, in response to a data backup request for a first virtual machine, the server obtains each first snapshot currently existing in the first virtual machine; the first virtual machine is configured with multiple first disks; each first snapshot corresponds to at least one first associated disk and the image file of each first associated disk at the creation time of the first snapshot; then, the server determines the first snapshot chain of the first virtual machine under the current data backup according to each first snapshot; the first snapshot chain is composed of each first snapshot, and each first snapshot is arranged in the first snapshot chain according to the creation time; then, the server traverses each first snapshot in the first snapshot chain in turn, and for each traversed first snapshot, backs up the image file under the first snapshot and records the backup location of the image file; finally, when the traversal of each first snapshot in the first snapshot chain is completed, the server determines the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine as the backup metadata of the first virtual machine under the current data backup, and saves the backup metadata; the backup metadata is used to implement a data recovery method for a virtual machine in claim 1. In this way, based on the first snapshots of the first virtual machine, the server can obtain the first snapshot chain of the first virtual machine. By backing up the image files of each first disk under each first snapshot in sequence according to the order of each first snapshot in the first snapshot chain, the server can back up the image files existing in the first virtual machine and obtain the backup metadata of the first virtual machine under the current data backup. Based on the backup metadata, the server can subsequently realize data recovery for the first virtual machine to avoid data loss of the virtual machine.

[0172] In an exemplary embodiment, as shown in FIG. 6 , the above step 504, determining the first snapshot chain of the first virtual machine under the current data backup according to each first snapshot, specifically includes the following steps:

[0173] Step S602, when the backup request is an incremental backup request, based on the backup metadata of the first virtual machine under the historical data backup, determine the first snapshot chain of the first virtual machine under the historical data backup, and determine each first snapshot in the first snapshot chain of the first virtual machine under the historical data backup as each first historical snapshot of the first virtual machine.

[0174] Step S604: determine each first snapshot currently existing in the first virtual machine, except each first historical snapshot, as each first current snapshot.

[0175] Step S606: Obtain a first snapshot chain of the first virtual machine under the current data backup according to each first current snapshot and the first snapshot chain of the first virtual machine under the historical data backup.

[0176] The incremental backup request refers to a backup request for incremental backup; backup includes incremental backup and full backup.

[0177] The historical data backup refers to the data backup last performed before the current data backup.

[0178] Specifically, after receiving the backup request, the server will detect the type of the backup request and determine whether the backup request is an incremental backup request or a full backup request; if the backup request is an incremental backup request, the server first obtains the backup metadata of the first virtual machine under the last data backup, and further obtains the first snapshot chain in the backup metadata under the last data backup, and then determines each first snapshot in the first snapshot chain under the last data backup as each first historical snapshot of the first virtual machine; then, the server removes each first historical snapshot from each first snapshot currently existing in the first virtual machine, obtains each first snapshot other than each first historical snapshot as each first current snapshot, and adds each first current snapshot to the first snapshot chain of the first virtual machine under the historical data backup, to obtain the first snapshot chain of the first virtual machine under the current data backup.

[0179] In this embodiment, the server can obtain the first current snapshots targeted by the current incremental backup by removing the first historical snapshots from the currently existing first snapshots, and can obtain the first snapshot chain of the first virtual machine under the current data backup based on the first current snapshots and the first snapshot chain of the first virtual machine under the historical data backup, thereby realizing this incremental backup.

[0180] In an exemplary embodiment, the data backup method of the virtual machine in any of the above embodiments specifically also includes the following contents, which are used to obtain a first snapshot and an image file: in response to a snapshot request for at least one first disk in the first virtual machine, the first disk targeted by the snapshot request is determined as a first associated disk of the first snapshot to be created; a snapshot taking operation is performed on the first associated disk, and an image file of the first associated disk at the current moment is generated, so as to obtain a first snapshot of the first associated disk at the current moment.

[0181] The current time is the time when the first snapshot is created.

[0182] Specifically, in response to a user's snapshot request for at least one first disk, the server determines each first disk targeted by the snapshot request as a first associated disk of a first snapshot to be created; then, the server performs a snapshot shooting operation on each first associated disk, and simultaneously generates an image file of each first associated snapshot at the current moment as the image file of each first associated snapshot under the first snapshot to be created, thereby obtaining the first snapshot of each first associated disk at the current moment, and determining the current moment as the creation moment of the first snapshot.

[0183] For example, assuming that for the first virtual machine VM1 configured with the first disk D1, the second disk D2 and the third disk D3, the server receives a snapshot request from the user for the first disk D1 and the second disk D2 at time T1, the server will perform a snapshot operation on the first disk D1 and the second disk D2, and generate an image file of the first disk D1 and the second disk D2 at time T1 as the image file of the first disk D1 and the second disk D2 under the first snapshot snapshot1 to be created, thereby obtaining the first snapshot of the first disk D1 and the second disk D2 at time T1.

[0184] In this embodiment, the server can obtain the first snapshot at the current moment by performing a first snapshot shooting operation and generating a mirror file for the snapshot request.

[0185] In an exemplary embodiment, as shown in FIG. 7 , a method for backing up and restoring data of a virtual machine is provided, which is described by taking the method applied to a server as an example, and includes the following steps:

[0186] Step S702: in response to a data backup request for a first virtual machine, obtaining each currently existing first snapshot of the first virtual machine, and determining a first snapshot chain of the first virtual machine under the current data backup according to each first snapshot.

[0187] Step S704: traverse the first snapshots in the first snapshot chain in sequence, back up the image file under the first snapshot being traversed for each first snapshot, and record the backup location of the image file.

[0188] Step S706, when the traversal of each first snapshot in the first snapshot chain is completed, the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine are determined as the backup metadata of the first virtual machine under the current data backup, and the backup metadata is saved.

[0189] Step S708: In response to a data recovery request for the first virtual machine, a second virtual machine with the same configuration as the first virtual machine is created, and a first snapshot chain in the backup metadata of the first virtual machine is obtained.

[0190] Step S710, traverse each first snapshot in the first snapshot chain in turn, and for each traversed first snapshot, create a second blank snapshot corresponding to the first snapshot being traversed in the second virtual machine, and, in each second disk, determine a second target disk corresponding to the first associated disk of the first snapshot being traversed.

[0191] Step S712: traverse each first associated disk of the first snapshot being traversed, and for each traversed first associated disk, obtain image file index information of a second target disk corresponding to the first associated disk being traversed.

[0192] Step S714, when the image file index information is empty, the image file of the first associated disk being traversed under the first snapshot is uploaded to the second virtual machine as the image file of the second target disk under the second blank snapshot, and the image file index information is modified to the file identifier of the image file.

[0193] Step S716, when the image file index information is not empty, modify the preceding image file attribute of the image file of the first associated disk being traversed under the first snapshot to the image file index information, obtain the modified image file, and upload the modified image file as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modify the image file index information to the file identifier of the modified image file.

[0194] Step S718, when all first associated snapshots of the first snapshot being traversed are traversed completely, a second snapshot of the second virtual machine corresponding to the first snapshot being traversed is obtained based on the image file of the second target disk of each first associated disk under the second blank snapshot.

[0195] Step S720: when all first snapshots in the first snapshot chain being traversed are completely traversed, a second snapshot chain of the second virtual machine is obtained according to second snapshots that correspond one-to-one to the first snapshots of the second virtual machine.

[0196] In this embodiment, first, based on each first snapshot of the first virtual machine, the server can obtain the first snapshot chain of the first virtual machine. By backing up the image files of each first disk under each first snapshot in sequence according to the order of each first snapshot in the first snapshot chain, the server can realize the backup of the image files existing in the first virtual machine and obtain the backup metadata of the first virtual machine under the current data backup. Based on the backup metadata, the server can subsequently realize data recovery for the first virtual machine to avoid data loss of the virtual machine. Then, based on the first snapshot chain in the backup metadata of the first virtual machine, the server can upload the image files of each first disk in the first virtual machine under each first snapshot as each image file of each second disk to the second virtual machine in sequence, obtain each second snapshot of the second virtual machine, and further form the second snapshot chain of the second virtual machine, so as to realize data recovery of the first virtual machine in the second virtual machine with the same configuration as the first virtual machine. Based on the above process, data recovery of the virtual machine can be realized to avoid data loss of the virtual machine.

[0197] In order to more clearly illustrate the data recovery method of the virtual machine and the data backup of the virtual machine provided in the embodiment of the present application, the data recovery method of the virtual machine and the data backup of the virtual machine provided in the present application are specifically described in a specific embodiment below, but it should be understood that the embodiment of the present application is not limited thereto. In one exemplary embodiment, the present application also provides a method for backing up and restoring a virtual machine based on a snapshot, which specifically includes the following contents:

[0198] In this embodiment, multiple disks are configured in the virtual machine. A snapshot can be taken for one or more of the multiple disks at a time, so each snapshot has a corresponding associated disk. Each snapshot corresponds to an image file of the associated disk at the creation time of the snapshot, and each image file has a corresponding backing file attribute of the preceding image file, which is used to record the file identifier of the previous image file of the disk to which the image file belongs. Among them, the virtual machine is an ovirt virtual machine, and the image file is a qocw2 file.

[0199] FIG8 shows the backup process in this embodiment:

[0200] 1. Obtain all current inactive first snapshots snap of the first virtual machine VM1, and sort them in the order in which they were created. If it is an incremental backup, filter out the first historical snapshot list prev_snaps used for the previous backup to obtain the first snapshot list snaps.

[0201] 2. If the first snapshot list snaps is empty, save the backup metadata and exit; otherwise, pop up the first snapshot snap from the first snapshot list snaps.

[0202] 3. Get the first associated disk list disks of the first snapshot snap.

[0203] 4. If the first associated disk list disks is empty, then the processing of the current first snapshot snap is terminated and the process returns to step 2; otherwise, the first first associated disk disk is ejected from the first associated disk list disks.

[0204] 5. Create an image download channel corresponding to the first snapshot snap for the first associated disk disk, download the image file image of the first associated disk disk under the first snapshot snap based on the image download channel, and return to step 4 after the download is completed.

[0205] FIG9 shows the recovery process in this embodiment:

[0206] 1. Read the backup metadata of the first virtual machine VM1.

[0207] 2. Create a second virtual machine VM2 with the same configuration as the first virtual machine VM1 according to the backup metadata; wherein the image file index information last_image_id of each second disk of the second virtual machine is initialized to empty, and is used to record the file identifier of an uploaded image file on the second disk.

[0208] 3. Read the first snapshot list src_snaps of the first virtual machine VM1 according to the backup metadata.

[0209] 4. If the first snapshot list src_snaps is empty, the recovery is terminated; otherwise, the first first snapshot src_snap is popped out from the first snapshot list src_snaps.

[0210] 5. Create a second snapshot snap for the second virtual machine VM2 using the first snapshot src_snap as a template.

[0211] 6. Get the first associated disk list disks of the first snapshot src_snap.

[0212] 7. If the first associated disk list disks is empty, then the processing of the current first snapshot src_snap is terminated and the process returns to step 4; otherwise, the first first associated disk disk is ejected from the first associated disk list disks.

[0213] 8. Create an image upload channel for the second disk disk corresponding to the first associated disk disk, and obtain the image file index information last_image_id of the first associated disk disk.

[0214] 9. If the image file index information last_image_id is empty, upload the image file image of the first associated disk disk under the first snapshot src_snap based on the image upload channel; otherwise, modify the image file attribute backing file of the image file image to the image file index information last_image_id before uploading.

[0215] 10. After the upload is completed, the image file index information last_image_id is updated to the image file identifier of the image file that has just been uploaded.

[0216] 11. Return to step 7.

[0217] Figure 10 shows the modification process of the image file's attribute backing file:

[0218] 1. Open the qcow2 file in read-write mode. The qcow2 file is the image file.

[0219] 2. Read the first 20 bytes of the qcow2 file.

[0220] 3. Parse the first 4 bytes in big-endian order. The type of the 4 bytes is uint32 and the value is magic.

[0221] 4. Parse the next 4 bytes in big-endian order. The type of these 4 bytes is uint32 and the value is version.

[0222] 5. Parse the next 8 bytes in big-endian order. The type of the 8 bytes is uint64 type, and the value is backingfile offset, that is, the offset value of the backing file attribute of the previous image file in the qcow2 file.

[0223] 6. Parse the last 4 bytes in big-endian order. The type of the 4 bytes is uint32 type, and the value is backingfile size, that is, the length of the backing file attribute of the previous image file, which should be the length of the file identifier of the image file image.

[0224] 7. Check the legitimacy of magic and version. If they are illegal, an error message will be given. Otherwise, go to step 8.

[0225] 8. Check whether the backing file size is equal to the length of the file identifier of the image file. If not, an error message is given and the process ends. Otherwise, go to step 9.

[0226] 9. Move the file offset to the backing file offset to overwrite the backing file.

[0227] 10. End.

[0228] It should be noted that there are currently two main methods for backing up and restoring ovirt virtual machines: the first is to create a proxy virtual machine in the ovirt system, then mount the virtual machine disk to be backed up and restored to the proxy virtual machine, and implement virtual machine backup and recovery by reading and writing device block files. The second is to use the backupapi provided by ovirt for backup and recovery.

[0229] However, firstly, although the backup and recovery of the mounting method is not limited to the version of ovirt, it can only backup and restore the virtual machine in the same data center as the proxy virtual machine, and because it directly reads and writes the block device file (raw format), it is difficult to support incremental backup. Secondly, although the backup and recovery method of the backup API method does not require the creation of a proxy virtual machine in the ovirt system and supports incremental backup, only the version of ovirt 4.4 or above can support the backup API; and in the related art, it is usually necessary to modify the backing file attribute of the qcow2 file with the help of a third-party qemu tool. In this embodiment, firstly, the backing file attribute of the image file in the qcow2 format of the ovirt system is fully utilized, which is the file identifier of the previous image file, and the snapshot chain of the second virtual machine can be reconstructed. Secondly, the composition characteristics of the first twenty bytes of the qcow2 format and the length of the backing file attribute and the length of the file identifier of the image file are fully utilized. The position of the backing file can be located by only parsing the first 20 bytes of the qcow2 file, so that the backing file attribute can be modified quickly and directly without affecting other contents of the qcow2 file. Based on the above process, this embodiment can support all versions after ovirt 4.0, and does not need to create a proxy virtual machine in the ovirt system. In addition, it also supports incremental backup and recovery, and can modify the backing file attributes of the qcow2 file without the help of a third-party qemu tool.

[0230] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0231] Based on the same inventive concept, the embodiment of the present application also provides a data recovery device for a virtual machine for implementing the data recovery method for the virtual machine involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the data recovery device embodiment of one or more virtual machines provided below can refer to the limitations of the data recovery method for the virtual machine above, and will not be repeated here.

[0232] In an exemplary embodiment, as shown in FIG. 11 , a data recovery device for a virtual machine is provided, comprising: a virtual machine creation module 1102 , a snapshot chain acquisition module 1104 , and a data recovery processing module 1106 , wherein:

[0233] The virtual machine creation module 1102 is used to create a second virtual machine with the same configuration as the first virtual machine in response to a data recovery request for the first virtual machine; the first virtual machine is configured with multiple first disks, and the second virtual machine is configured with each second disk corresponding to each first disk.

[0234] The snapshot chain acquisition module 1104 is used to obtain the first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain consists of multiple first snapshots; each first snapshot corresponds to at least one first associated disk and the image file of each first associated disk at the time of creation of the first snapshot.

[0235] The data recovery processing module 1106 is used to upload each image file corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain, obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of each second snapshot, so as to complete the data recovery of the first virtual machine.

[0236] In an exemplary embodiment, each image file has a corresponding preceding image file attribute, which is used to record the file identifier of the previous image file of the disk to which the image file belongs; each second disk has corresponding image file index information, which is used to record the file identifier of an uploaded image file on the second disk, and the image file index information is initialized to empty.

[0237] The data recovery processing module 1106 is further used to sequentially traverse each first snapshot in the first snapshot chain, and for each traversed first snapshot, create a second blank snapshot corresponding to the first snapshot in the second virtual machine, and, in each second disk, determine a second target disk corresponding to the first associated disk of the first snapshot; sort the first snapshots in the first snapshot chain in chronological order according to their respective creation times; based on the modification of the preceding image file attribute of the image file under the first snapshot and the modification of the image file index information of the second target disk, upload the image file under the first snapshot to the second virtual machine as the image file of the second target disk under the second blank snapshot, and obtain a second snapshot corresponding to the first snapshot; and obtain a second snapshot chain of the second virtual machine according to the second snapshots that correspond one-to-one between the second virtual machine and each first snapshot.

[0238] In an exemplary embodiment, the data recovery processing module 1106 is further used to traverse each first associated disk of the first snapshot, and for each traversed first associated disk, obtain the image file index information of the second target disk corresponding to the first associated disk; when the image file index information is empty, upload the image file of the first associated disk under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modify the image file index information to the file identifier of the image file; when the image file index information is not empty, modify the pre-order image file attribute of the image file of the first associated disk under the first snapshot to the image file index information to obtain the modified image file, upload the modified image file as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modify the image file index information to the file identifier of the modified image file; based on the image file of the second target disk of each first associated disk under the second blank snapshot, obtain the second snapshot of the second virtual machine corresponding to the first snapshot.

[0239] In an exemplary embodiment, the preceding image file attributes of the image file are recorded in the image file.

[0240] The data recovery processing module 1106 is also used to read the preset field of the image file; the preset field records the offset value of the preceding image file attribute of the image file in the image file; the preset field is verified; if the preset field verification passes, the offset value in the preset field is read; based on the offset value, the preceding image file attribute of the image file is read, and the preceding image file attribute of the image file is modified.

[0241] In an exemplary embodiment, the backup metadata of the first virtual machine also includes configuration information of the first virtual machine and backup locations of each image file corresponding to the first snapshot chain.

[0242] The virtual machine creation module 1102 is further configured to create a second virtual machine having the same configuration as the first virtual machine based on the configuration information in the backup metadata of the first virtual machine.

[0243] The data recovery processing module 1106 is further used to obtain each image file corresponding to the first snapshot chain based on the backup location of each image file corresponding to the first snapshot chain in the backup metadata of the first virtual machine.

[0244] Based on the same inventive concept, the embodiment of the present application also provides a data backup device for a virtual machine for implementing the data backup method for the virtual machine involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the data backup device embodiment of one or more virtual machines provided below can refer to the limitations of the data backup method for the virtual machine above, and will not be repeated here.

[0245] In an exemplary embodiment, as shown in FIG. 12 , a data backup device for a virtual machine is provided, comprising: a first snapshot acquisition module 1202, a snapshot chain determination module 1204, an image file backup module 1206, and a backup data storage module 1208, wherein:

[0246] The first snapshot acquisition module 1202 is used to respond to a data backup request for the first virtual machine and obtain each first snapshot currently existing in the first virtual machine; multiple first disks are configured in the first virtual machine; each first snapshot corresponds to at least one first associated disk and the image file of each first associated disk at the time of creation of the first snapshot.

[0247] The snapshot chain determination module 1204 is used to determine the first snapshot chain of the first virtual machine under the current data backup according to each first snapshot; the first snapshot chain is composed of each first snapshot, and each first snapshot is sorted in the first snapshot chain according to their respective creation time.

[0248] The image file backup module 1206 is used to traverse each first snapshot in the first snapshot chain in sequence, back up the image file under each traversed first snapshot, and record the backup location of the image file.

[0249] The backup data saving module 1208 is used to determine the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine as the backup metadata of the first virtual machine under the current data backup, and save the backup metadata when the traversal of each first snapshot in the first snapshot chain is completed; the backup metadata is used to implement the data recovery method of the virtual machine in any of the above embodiments.

[0250] In an exemplary embodiment, the snapshot chain determination module 1204 is also used to determine the first snapshot chain of the first virtual machine under the historical data backup based on the backup metadata of the first virtual machine under the historical data backup when the backup request is an incremental backup request, and determine each first snapshot in the first snapshot chain of the first virtual machine under the historical data backup as each first historical snapshot of the first virtual machine; determine each first snapshot currently existing in the first virtual machine, except for each first historical snapshot, as each first current snapshot; and obtain the first snapshot chain of the first virtual machine under the current data backup based on each first current snapshot and the first snapshot chain of the first virtual machine under the historical data backup.

[0251] In an exemplary embodiment, the data backup device of the virtual machine also includes a disk snapshot shooting module, which is used to respond to a snapshot request for at least one first disk in the first virtual machine, determine the first disk targeted by the snapshot request as the first associated disk of the first snapshot to be created; perform a snapshot shooting operation on the first associated disk, and generate an image file of the first associated disk at the current moment, to obtain the first snapshot of the first associated disk at the current moment; the current moment is the creation moment of the first snapshot.

[0252] Each module in the data recovery device of the virtual machine and the data backup device of the virtual machine can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0253] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG13. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store backup metadata of the virtual machine. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data recovery method for a virtual machine and a data backup method for a virtual machine are implemented.

[0254] Those skilled in the art will understand that the structure shown in FIG. 13 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0255] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0256] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0257] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0258] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0259] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0260] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for recovering data of a virtual machine, characterized in that: The method comprises: In response to a data recovery request for a first virtual machine, creating a second virtual machine with the same configuration as the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding one to one to the respective first disks; Obtaining a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot; Based on the first snapshot chain, each image file corresponding to the first snapshot chain is uploaded to the second virtual machine in sequence to obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

2. The method according to claim 1, characterized in that Each image file has a corresponding pre-order image file attribute, and the pre-order image file attribute is used to record the file identifier of the previous image file of the disk to which the image file belongs; each second disk has corresponding image file index information, and the image file index information is used to record the file identifier of an uploaded image file on the second disk, and the image file index information is initialized to be empty; The method of uploading the image files corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain to obtain second snapshots corresponding to the first snapshots and a second snapshot chain composed of the second snapshots includes: traversing each first snapshot in the first snapshot chain in sequence, and for each traversed first snapshot, creating a second blank snapshot corresponding to the first snapshot in the second virtual machine, and determining, among the second disks, a second target disk corresponding to the first associated disk of the first snapshot; the first snapshots are sorted in the first snapshot chain in chronological order according to their respective creation times; Based on the modification of the preceding image file attribute of the image file under the first snapshot and the modification of the image file index information of the second target disk, the image file under the first snapshot is uploaded to the second virtual machine as the image file of the second target disk under the second blank snapshot, so as to obtain a second snapshot corresponding to the first snapshot; A second snapshot chain of the second virtual machine is obtained according to the second snapshots that correspond one-to-one between the second virtual machine and the first snapshots.

3. The method according to claim 2, characterized in that The method of uploading the image file under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine based on the modification of the preceding image file attribute of the image file under the first snapshot and the modification of the image file index information of the second target disk to obtain a second snapshot corresponding to the first snapshot includes: Traversing each first associated disk of the first snapshot, and for each traversed first associated disk, acquiring image file index information of a second target disk corresponding to the first associated disk; When the image file index information is empty, uploading the image file of the first associated disk under the first snapshot as the image file of the second target disk under the second blank snapshot to the second virtual machine, and modifying the image file index information to the file identifier of the image file; In the case where the image file index information is not empty, modifying the pre-order image file attribute of the image file of the first associated disk under the first snapshot to the image file index information to obtain a modified image file, uploading the modified image file to the second virtual machine as the image file of the second target disk under the second blank snapshot, and modifying the image file index information to the file identifier of the modified image file; Based on the image file of the second target disk of each first associated disk under the second blank snapshot, a second snapshot of the second virtual machine corresponding to the first snapshot is obtained.

4. The method according to claim 2, characterized in that: The preceding image file attributes of the image file are recorded in the image file; The modification of the preceding image file attribute of the image file under the first snapshot is achieved by the following process: Reading a preset field of the image file; the preset field records an offset value of a preceding image file attribute of the image file in the image file; Verifying the preset field; In the case where the preset field is verified, reading the offset value in the preset field; Based on the offset value, the preceding image file attribute of the image file is read, and the preceding image file attribute of the image file is modified.

5. The method according to any one of claims 1 to 4, characterized in that: The backup metadata of the first virtual machine also includes configuration information of the first virtual machine and backup locations of each image file corresponding to the first snapshot chain; The creating a second virtual machine having the same configuration as the first virtual machine includes: Creating, based on the configuration information in the backup metadata of the first virtual machine, the second virtual machine having the same configuration as the first virtual machine; Before uploading the image files corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain to obtain second snapshots corresponding to the first snapshots and a second snapshot chain composed of the second snapshots, the method further includes: Based on the backup locations of the image files corresponding to the first snapshot chain in the backup metadata of the first virtual machine, the image files corresponding to the first snapshot chain are obtained.

6. A data backup method for a virtual machine, characterized in that: The method comprises: In response to a data backup request for a first virtual machine, obtaining each first snapshot currently existing in the first virtual machine; a plurality of first disks are configured in the first virtual machine; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creating the first snapshot; Determine, according to the first snapshots, a first snapshot chain of the first virtual machine under the current data backup; the first snapshot chain is composed of the first snapshots, and the first snapshots are arranged in the first snapshot chain in chronological order according to their respective creation times; Traversing each first snapshot in the first snapshot chain in sequence, backing up the image file under each traversed first snapshot, and recording the backup location of the image file; When the traversal of each first snapshot in the first snapshot chain is completed, the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine are determined as the backup metadata of the first virtual machine under the current data backup, and the backup metadata is saved; the backup metadata is used to implement the data recovery method of the virtual machine described in any one of claims 1 to 5.

7. The method according to claim 6, characterized in that The determining, according to the first snapshots, a first snapshot chain of the first virtual machine under the current data backup includes: In the case where the backup request is an incremental backup request, based on the backup metadata of the first virtual machine under the historical data backup, determining a first snapshot chain of the first virtual machine under the historical data backup, and determining each first snapshot in the first snapshot chain of the first virtual machine under the historical data backup as each first historical snapshot of the first virtual machine; Determine, among the first snapshots currently existing in the first virtual machine, the first snapshots other than the first historical snapshots as first current snapshots; According to the first current snapshots and the first snapshot chain of the first virtual machine under the historical data backup, a first snapshot chain of the first virtual machine under the current data backup is obtained.

8. The method according to claim 6, characterized in that The method further comprises: In response to a snapshot request for at least one first disk in the first virtual machine, determining the first disk targeted by the snapshot request as a first associated disk of a first snapshot to be created; A snapshot operation is performed on the first associated disk, and an image file of the first associated disk at the current moment is generated, so as to obtain a first snapshot of the first associated disk at the current moment; the current moment is a creation moment of the first snapshot.

9. A data recovery device for a virtual machine, characterized in that: The device comprises: A virtual machine creation module, configured to create a second virtual machine with the same configuration as the first virtual machine in response to a data recovery request for the first virtual machine; the first virtual machine is configured with a plurality of first disks, and the second virtual machine is configured with respective second disks corresponding to the respective first disks one by one; A snapshot chain acquisition module, used to acquire a first snapshot chain in the backup metadata of the first virtual machine; the first snapshot chain is composed of a plurality of first snapshots; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creation of the first snapshot; A data recovery processing module is used to upload each image file corresponding to the first snapshot chain to the second virtual machine in sequence based on the first snapshot chain, obtain each second snapshot corresponding to each first snapshot and a second snapshot chain composed of the second snapshots, so as to complete the data recovery of the first virtual machine.

10. A data backup device for a virtual machine, characterized in that: The device comprises: A first snapshot acquisition module is used to obtain each first snapshot currently existing in the first virtual machine in response to a data backup request for the first virtual machine; the first virtual machine is configured with multiple first disks; each first snapshot corresponds to at least one first associated disk and an image file of each first associated disk at the time of creating the first snapshot; a snapshot chain determination module, configured to sequentially traverse each first snapshot in the first snapshot chain, back up the image file under each traversed first snapshot, and record the backup location of the image file; an image file backup module, configured to traverse the first snapshots in the first snapshot chain in sequence, back up the image file under each traversed first snapshot, and record the backup location of the image file; A backup data saving module, used to determine the first snapshot chain, the backup location of each image file corresponding to the first snapshot chain, and the configuration information of the first virtual machine as the backup metadata of the first virtual machine under the current data backup when the traversal of each first snapshot in the first snapshot chain is completed, and save the backup metadata; the backup metadata is used to implement the data recovery method of the virtual machine described in any one of claims 1 to 5.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the virtual machine data recovery method according to any one of claims 1 to 5 or the virtual machine data backup method according to any one of claims 6 to 8 are implemented.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the virtual machine data recovery method according to any one of claims 1 to 5 or the virtual machine data backup method according to any one of claims 6 to 8 are implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the virtual machine data recovery method according to any one of claims 1 to 5 or the virtual machine data backup method according to any one of claims 6 to 8 are implemented.

Citation Information

Patent Citations

  • Virtual machine snapshot generation method and device, electronic equipment and medium

    CN112698913A

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

    CN115098299A

  • Snapshot management method and system and computer readable medium

    CN115658239A

  • Backup method and device of virtual machine

    CN117032884A

  • Data recovery method and device, equipment, storage medium and computer program product

    CN117370079A