Backup recovery method and device of virtual machine, computer equipment, readable storage medium and program product

By starting the backup virtual machine in the host, loading and mounting virtual disk files, and generating mount information, the problem of poor backup and recovery of virtual machines in the existing technology is solved, and an efficient and reliable backup and recovery process is achieved.

CN119415317AActive Publication Date: 2025-02-11GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411422404.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-02-11
Estimated Expiration
2044-10-12

AI Technical Summary

Technical Problem

When existing file-level recovery methods deal with complex scenarios, they can easily affect the stability of the storage system, resulting in poor backup and recovery reliability of virtual machines.

Method used

By starting the backup virtual machine in the host, loading and mounting the virtual disk files in the backup set as a block device, generating mount information, and restoring the target file in response to user requests.

Benefits of technology

Isolation of virtual machine backup and recovery is achieved, system stability and resource utilization efficiency is improved, dependence on the host file system is reduced, and the reliability and recovery efficiency of the backup and recovery process are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415317A_ABST
    Figure CN119415317A_ABST
Patent Text Reader

Abstract

The invention relates to a backup recovery method and device of a virtual machine, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: in response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine; taking the virtual disk file in the backup set as a block device of the backup virtual machine, and loading the block device in the backup virtual machine; after the loading processing is completed, carrying out mounting processing on a virtual disk corresponding to the block device in a backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk; in response to a recovery request for the target file, recovering the target file by backing up the virtual machine and the mounting information; the target file is a file of the target virtual machine. By adopting the method, the backup recovery reliability of the virtual machine can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of virtualization technology, more and more enterprises are beginning to run their core businesses on virtual machines. Currently, usually through file-level recovery, users can quickly extract and restore the required files or directories from the virtual machine backup set without restoring the entire virtual machine image.

[0003] However, existing file-level recovery methods still have defects when dealing with complex scenarios, which can easily affect the stability of the storage system, resulting in poor reliability of virtual machine backup and recovery. Summary of the invention

[0004] Based on this, it is necessary to provide a virtual machine backup and recovery method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the reliability of virtual machine backup and recovery in order to solve the above technical problems.

[0005] In a first aspect, the present application provides a virtual machine backup and recovery method, comprising:

[0006] In response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine;

[0007] Using the virtual disk file in the backup set as the block device of the backup virtual machine, and loading the block device in the backup virtual machine;

[0008] After the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk;

[0009] In response to a recovery request for a target file, the target file is recovered through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

[0010] In one embodiment, mounting the virtual disk corresponding to the block device in the backup virtual machine so that the backup virtual machine generates mounting information of the virtual disk includes:

[0011] In the backup virtual machine, identifying a partition structure in the virtual disk, and identifying a partition type corresponding to each partition in the virtual disk;

[0012] In the backup virtual machine, creating a corresponding mount point directory for each partition in the virtual disk;

[0013] In the backup virtual machine, each partition in the virtual disk is mounted to a corresponding mount point according to the partition type and the mount point directory, and the mount point directory is used as the mount information.

[0014] In one embodiment, after starting the backup virtual machine in the host machine, the method further includes:

[0015] Establishing a communication connection between the host machine and the backup virtual machine;

[0016] Before restoring the target file through the backup virtual machine and the mount information, the method further includes:

[0017] Through the communication connection, the host machine obtains the mounting information in the backup virtual machine and displays the mounting information.

[0018] In one embodiment, in response to a recovery request for a target file, recovering the target file by using the backup virtual machine and the mount information includes:

[0019] In response to a user's request to restore the target file in the mount information, obtaining file data of the target file from the backup virtual machine through the communication connection;

[0020] The file data is saved to a user-specified location.

[0021] In one embodiment, establishing a communication connection between the host machine and the backup virtual machine includes:

[0022] Obtaining performance information of the host machine;

[0023] Determining a target communication connection type from preset communication connection types according to the performance information;

[0024] A communication connection corresponding to the target communication connection type is established between the host machine and the backup virtual machine.

[0025] In one embodiment, starting the backup virtual machine in the host machine includes:

[0026] Get the preset virtual machine type;

[0027] A minimally configured virtual machine corresponding to the preset virtual machine type is started in the host machine as the backup virtual machine.

[0028] In a second aspect, the present application also provides a virtual machine backup and recovery device, including:

[0029] A virtual machine startup module, used to start a backup virtual machine in a host machine in response to any operation request for a backup set of a target virtual machine; the target virtual machine is a virtual machine to be backed up in the host machine;

[0030] A block device loading module, used to use the virtual disk file in the backup set as the block device of the backup virtual machine, and load the block device in the backup virtual machine;

[0031] A mounting processing module, used for mounting the virtual disk corresponding to the block device in the backup virtual machine after the loading process is completed, so that the backup virtual machine generates mounting information of the virtual disk;

[0032] The file recovery module is used to respond to a recovery request for a target file and recover the target file through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

[0033] In a third aspect, the present application further provides a computer device, including 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:

[0034] In response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine;

[0035] Using the virtual disk file in the backup set as the block device of the backup virtual machine, and loading the block device in the backup virtual machine;

[0036] After the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk;

[0037] In response to a recovery request for a target file, the target file is recovered through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

[0038] In a fourth 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:

[0039] In response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine;

[0040] Using the virtual disk file in the backup set as the block device of the backup virtual machine, and loading the block device in the backup virtual machine;

[0041] After the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk;

[0042] In response to a recovery request for a target file, the target file is recovered through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

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

[0044] In response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine;

[0045] Using the virtual disk file in the backup set as the block device of the backup virtual machine, and loading the block device in the backup virtual machine;

[0046] After the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk;

[0047] In response to a recovery request for a target file, the target file is recovered through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

[0048] The above-mentioned virtual machine backup and recovery method, device, computer equipment, computer-readable storage medium and computer program product firstly start the backup virtual machine in the host machine in response to any operation request for the backup set of the target virtual machine, wherein the target virtual machine is the virtual machine to be backed up in the host machine. By starting a dedicated backup virtual machine in the host machine, the backup and recovery operation can be isolated from other tasks of the host machine, reducing the impact of the backup operation on the normal business of the host machine, and improving the stability and security of the system. At the same time, the startup of the backup virtual machine responds to user requests, has good operational flexibility, supports on-demand startup, and improves resource utilization; then, the virtual disk file in the backup set is used as the block device of the backup virtual machine, and the block device is loaded and processed in the backup virtual machine. By loading the virtual disk file as a block device into the backup virtual machine, a complete disk operation environment can be simulated, so that the backup virtual machine can The data in the disk is processed independently, and the backup virtual machine can directly read and operate the data in the backup set without relying on the file system of the host machine, which greatly improves the flexibility of operation and the security of data; then, after the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates the mounting information of the virtual disk, and the mounting operation enables the backup virtual machine to identify and access the partitions and file systems in the virtual disk. The generated mounting information can provide a clear path and structure for subsequent file operations, ensuring the accuracy and reliability of file recovery; finally, in response to the recovery request for the target file, the target file is restored through the backup virtual machine and the mounting information, wherein the target file is a file of the target virtual machine, the target file is accurately located through the mounting information, and the file recovery operation is performed through the backup virtual machine, avoiding a large amount of data duplication and redundant operations in the traditional recovery method. In the above method, by starting an independent backup virtual machine on the host machine, the isolation of backup and recovery operations is achieved, which significantly improves the stability and resource utilization efficiency of the system. Loading and mounting virtual disk files in the backup virtual machine avoids excessive dependence on the host file system, reduces the impact of complex file systems and partition conflicts on the system, and improves the reliability of the backup and recovery process. Through file-level recovery operations, users can quickly extract target files or directories, avoiding redundant data processing in traditional full disk recovery and greatly improving recovery efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] 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.

[0050] FIG1 is a diagram of an application environment of a method for backing up and restoring a virtual machine in one embodiment;

[0051] FIG2 is a schematic diagram of a flow chart of a method for backing up and restoring a virtual machine in one embodiment;

[0052] FIG3 is a schematic diagram of a flow chart of a method for backing up and restoring a virtual machine in another embodiment;

[0053] FIG4 is a structural block diagram of a backup and recovery device for a virtual machine in one embodiment;

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

[0055] 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.

[0056] The backup and recovery method of the virtual machine provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the backup virtual machine 104 runs in the host machine 102. The data storage system can store the data that the host machine 102 needs to process. The data storage system can be integrated on the host machine 102, or it can be placed on the cloud or other network servers. The host machine 102 responds to any operation request for the backup set of the target virtual machine, and starts the backup virtual machine 104 in the host machine 102; the target virtual machine is the virtual machine to be backed up in the host machine; the host machine 102 uses the virtual disk file in the backup set as the block device of the backup virtual machine 104, and loads the block device in the backup virtual machine 104; after the loading process is completed, the backup virtual machine 104 mounts the virtual disk corresponding to the block device in the backup virtual machine 104, so that the backup virtual machine generates the mounting information of the virtual disk; the host machine 102 responds to the recovery request for the target file, and restores the target file through the backup virtual machine 104 and the mounting information; the target file is the file of the target virtual machine. Among them, the host machine 102 can be but is not limited to a terminal or a server, wherein the terminal can be but is not limited to various personal computers, laptops, etc., and the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0057] In an exemplary embodiment, as shown in FIG. 2 , a method for backing up and restoring a virtual machine is provided, which is described by taking the method applied to the host machine 102 in FIG. 1 as an example, and includes the following steps:

[0058] Step S201 , in response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine.

[0059] The target virtual machine is the virtual machine to be backed up in the host machine.

[0060] The host machine is a physical server that runs multiple virtual machines and is responsible for managing the virtualized environment, on which virtual machines can be started, stopped, and managed.

[0061] The backup virtual machine is a virtual machine specifically used to perform backup and recovery tasks and is started in the host machine.

[0062] For example, when a user initiates an operation request for the backup set of the target virtual machine (such as restoring files, checking backup status, performing backup verification, viewing specific files or directories, etc.), the host machine calls the virtualization management interface (such as QEMU / KVM, VMware or Hyper-V) to start the backup virtual machine and allocate resources (such as CPU, memory, storage space) to meet the needs of backup and recovery tasks. After startup, the backup virtual machine will run on the host machine and provide an independent environment for subsequent virtual disk mounting and data recovery operations.

[0063] Step S202: Use the virtual disk file in the backup set as a block device of the backup virtual machine, and load the block device into the backup virtual machine.

[0064] The virtual disk file is the data storage form of the target virtual machine, which contains all the data generated during the operation of the virtual machine, including the operating system, applications, and user data. Block devices are abstract devices used to store data. By using the virtual disk file as a block device, the backup virtual machine can directly read and operate the data in the virtual disk. The loading process refers to connecting the block device to the backup virtual machine so that it can access the data structure in the virtual disk and prepare to mount and operate the data.

[0065] Exemplarily, when the backup virtual machine is started, the host machine selects the virtual disk file (such as VMDK, QCOW2, etc. format) of the target virtual machine from the backup set, and configures the virtual disk file as a block device of the backup virtual machine. The host machine associates the virtual disk file with the block device of the backup virtual machine through the virtualization management interface, similar to connecting a physical hard disk to a virtual machine. Subsequently, the backup virtual machine identifies the block device through a loading operation and processes it as an accessible storage device. Furthermore, the backup virtual machine can access the partition and file data in the virtual disk through file system operations, preparing for subsequent mounting and file recovery operations.

[0066] Step S203, after the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk.

[0067] The virtual disk corresponding to the block device refers to the data storage structure in the block device loaded by the backup virtual machine, which usually contains the partition, file system and data of the target virtual machine. The mount process refers to mapping the virtual disk file system to the file system of the backup virtual machine, so that the backup virtual machine can access the files and directories in the virtual disk through the specified mount point. The mount information includes the mount path, partition structure, file system type, etc. of the virtual disk, which is used for subsequent file recovery operations.

[0068] Exemplarily, the mount operation can be completed by the backup virtual machine itself through a pre-configured startup script, or directly controlled by the host machine through a virtualization management platform. For the automated solution, the backup virtual machine will run an initialization script after startup, automatically detect the loaded virtual disk file, and create a mount point (such as / mnt / partition1) for each partition in turn according to the partition structure and file system type of the disk file, and mount the corresponding partition to the file system of the backup virtual machine. The script will load the corresponding driver according to different file system types (such as EXT4, NTFS, etc.) to ensure that the partition can be correctly identified and operated. In addition, the host machine can also directly control the mount process through the virtualization management interface. The host machine instructs the backup virtual machine to perform the mount operation by remotely calling the management interface of the backup virtual machine, or directly executes a command on the host machine to force the backup virtual machine to mount the virtual disk to the specified directory. At this time, the host machine will obtain the mount information of the backup virtual machine, including the mount point path, partition identifier, file system type, etc., to ensure that the host machine can obtain the current status and structure of the virtual disk at any time. In addition, whether through the automatic script of the backup virtual machine or the remote control of the host machine, mount information will be generated after the mount operation is completed. This information is used to accurately locate the files and directories in the virtual disk and support subsequent file recovery operations.

[0069] Step S204, in response to the recovery request for the target file, the target file is recovered by backing up the virtual machine and mounting information.

[0070] The target file is a file of the target virtual machine.

[0071] The target file refers to a specific file or directory that the user wants to extract and restore from the backup set of the target virtual machine. The restore request is an operation command issued by the user or the system to extract and restore a specific file from the virtual disk.

[0072] Exemplarily, a user initiates a file recovery request through a host machine, and the request specifies a specific file or directory of a target virtual machine. The backup virtual machine first locates the file system and partition structure in the virtual disk of the target virtual machine based on the previously generated mount information. Then, the backup virtual machine accesses the specific file system in the virtual disk through the mount point, and uses the file path in the mount information to accurately locate the target file specified by the user. In response to the user's request, the backup virtual machine will directly read the target file from the mounted virtual disk and transfer it back to the host machine, or restore the file to the specified storage path according to the user's requirements. For example, the backup virtual machine can send the target file to the host machine through a network communication protocol (such as HTTP, FTP, etc.), or copy the file to a specified directory of the host machine through a file system operation. The host machine can perform multiple recovery operations at the same time, recovering different target files one by one, thereby improving the recovery efficiency of the system. In addition, the recovery operation is not limited to a specific type of file. The backup virtual machine can accurately read any file type (such as text files, database files, etc.) of the target virtual machine through the mount information to ensure the wide applicability of the recovery operation.

[0073] In the above-mentioned virtual machine backup and recovery method, first, in response to any operation request for the backup set of the target virtual machine, the backup virtual machine is started in the host machine, wherein the target virtual machine is the virtual machine to be backed up in the host machine. By starting a dedicated backup virtual machine in the host machine, the backup and recovery operation can be isolated from other tasks of the host machine, reducing the impact of the backup operation on the normal business of the host machine, and improving the stability and security of the system. At the same time, the startup of the backup virtual machine responds to user requests, has good operational flexibility, supports on-demand startup, and improves resource utilization; then, the virtual disk file in the backup set is used as the block device of the backup virtual machine, and the block device is loaded and processed in the backup virtual machine. By loading the virtual disk file as a block device into the backup virtual machine, a complete disk operation environment can be simulated, so that the backup virtual machine can independently process the data in the virtual disk. The backup virtual machine can directly read and operate the data in the backup set without relying on the file system of the host machine, which greatly improves the flexibility of operation and the security of data; then, after the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates the mounting information of the virtual disk, and the mounting operation enables the backup virtual machine to identify and access the partitions and file systems in the virtual disk. The generated mounting information can provide a clear path and structure for subsequent file operations, ensuring the accuracy and reliability of file recovery; finally, in response to the recovery request for the target file, the target file is restored through the backup virtual machine and the mounting information, wherein the target file is a file of the target virtual machine, the target file is accurately located through the mounting information, and the file recovery operation is performed through the backup virtual machine, avoiding a large amount of data duplication and redundant operations in the traditional recovery method. In the above method, by starting an independent backup virtual machine on the host machine, the isolation of backup and recovery operations is achieved, which significantly improves the stability and resource utilization efficiency of the system. Loading and mounting virtual disk files in the backup virtual machine avoids excessive dependence on the host file system, reduces the impact of complex file systems and partition conflicts on the system, and improves the reliability of the backup and recovery process. Through file-level recovery operations, users can quickly extract target files or directories, avoiding redundant data processing in traditional full disk recovery and greatly improving recovery efficiency.

[0074] In an exemplary embodiment, the above step S203 mounts the virtual disk corresponding to the block device in the backup virtual machine, so that the backup virtual machine generates the mounting information of the virtual disk, and also includes: in the backup virtual machine, identifying the partition structure in the virtual disk, and identifying the partition type corresponding to each partition in the virtual disk; in the backup virtual machine, creating a corresponding mount point directory for each partition in the virtual disk; in the backup virtual machine, according to the partition type and the mount point directory, mounting each partition in the virtual disk to the corresponding mount point, and using the mount point directory as the mounting information.

[0075] The partition structure refers to the logical partition layout in the virtual disk, such as primary partition, extended partition, etc. The partition type refers to the file system type of each partition, such as EXT4, NTFS, etc. The mount point directory is the file system entry created by the backup virtual machine for each partition, which is used to access the data in the virtual disk.

[0076] For example, when the block device is successfully loaded into the backup virtual machine, the backup virtual machine will automatically identify the partition structure in the virtual disk and load the corresponding file system driver according to the type of each partition. Then, the backup virtual machine will create a mount point directory for each partition, such as / mnt / partition1, / mnt / partition2, and mount each partition to the corresponding mount point directory, so that the backup virtual machine can access the file system in the virtual disk through these mount points. The mount information includes data such as the mount point directory, partition structure, and partition type, ensuring that the backup virtual machine can accurately locate and access files in the virtual disk.

[0077] In this embodiment, by automatically identifying the partition structure and partition type and creating a mount point directory for each partition, efficient mounting of the virtual disk is achieved. This mounting process reduces manual intervention and improves the efficiency of the backup virtual machine's operation on the virtual disk. The generation of mounting information ensures the accuracy and speed of the file recovery operation, while reducing the system resource usage during the backup and recovery process, and improving the efficiency and reliability of the overall backup and recovery process.

[0078] In an exemplary embodiment, after the backup virtual machine is started in the host machine in the above step S201, the step further includes: establishing a communication connection between the host machine and the backup virtual machine.

[0079] Before the above step S204 restores the target file by backing up the virtual machine and mounting the information, the process further includes: the host machine obtains the mounting information in the backup virtual machine through the communication connection, and displays the mounting information.

[0080] The communication connection refers to the connection channel established between the host machine and the backup virtual machine for data interaction and control command transmission, which may be based on the dedicated communication protocol (such as vsocket) or standard network protocol (such as TCP / IP) provided by the virtualization platform. This connection ensures that the host machine can exchange information with the backup virtual machine in real time, especially to obtain key mount information during file recovery operations.

[0081] Exemplarily, after the backup virtual machine is started, the host machine calls the communication interface through the virtualization management platform to establish a communication connection between the host machine and the backup virtual machine. The communication connection can ensure that the host machine monitors the status of the backup virtual machine in real time and sends control commands to perform backup and recovery operations. In addition, the communication connection can also be used to transmit the mount information generated by the backup virtual machine so that the host machine can use it in the recovery operation. This connection mechanism can use the dedicated communication channel provided by the virtual machine manager or be established through a standard network protocol to ensure the flexibility and stability of communication. After the backup virtual machine mounts the virtual disk, the host machine sends a request to the backup virtual machine through the communication connection to obtain the mount information generated by the backup virtual machine. The mount information usually includes metadata such as the mount point path, partition structure, and file system type, which is used to locate files and directories in the virtual disk. After obtaining this information, the host machine will display it in the user interface, and the user can browse the directory structure of the virtual disk and select the target file to be restored. Displaying the mount information can also support the automated recovery process. The system automatically selects the appropriate file for recovery operation based on the mount information to ensure the efficiency and accuracy of the recovery process.

[0082] In this embodiment, by establishing a communication connection between the host machine and the backup virtual machine, the real-time transmission and display of the mount information is ensured. The user or the system can quickly locate and select the target file to be restored based on the displayed mount information, which greatly improves the efficiency of the file recovery operation. At the same time, by obtaining the mount information through the communication connection, the host machine can grasp the mount status of the backup virtual machine in real time, ensuring the stability and reliability of the backup and recovery process.

[0083] In an exemplary embodiment, the above step S204 responds to a request to recover the target file by backing up the virtual machine and mounting information, and also includes: in response to a user's request to recover the target file in the mount information, obtaining the file data of the target file from the backup virtual machine through a communication connection; and saving the file data to a user-specified location.

[0084] The file data is the content of the target file.

[0085] Exemplarily, when the user selects the target file in the mount information through the interface or system command on the host machine, the host machine sends a file recovery request to the backup virtual machine. The backup virtual machine locates the target file in the mounted virtual disk according to the user's selection and reads the file data of the file. Through the communication connection, the backup virtual machine transmits the file data back to the host machine. After the host machine receives the file data, it saves the file data to the local storage of the host machine or other network storage devices according to the storage path pre-specified by the user. The host machine can execute multiple file recovery tasks at the same time, each task will correspond to different files or directories, and different save paths can be specified respectively to ensure the flexibility of file recovery and multi-tasking capabilities.

[0086] In this embodiment, by responding to the user's request to restore the target file in the mount information, the backup virtual machine can quickly and accurately extract the data of the target file and transmit it to the host machine through the communication connection. The user can freely choose the save location of the target file to ensure flexibility and accuracy in the file recovery process. It not only reduces the complexity of data transmission, but also optimizes the collaborative operation between the backup virtual machine and the host machine, and improves the efficiency of the file recovery operation. Through this mechanism, users can quickly restore the required files and perform subsequent operations on them at the specified location, meeting the needs of data recovery in different business scenarios.

[0087] In an exemplary embodiment, the above-mentioned establishment of a communication connection between the host machine and the backup virtual machine also includes: obtaining performance information of the host machine; determining a target communication connection type from preset communication connection types based on the performance information; and establishing a communication connection corresponding to the target communication connection type between the host machine and the backup virtual machine.

[0088] Exemplarily, during the process of establishing a communication connection, the current performance information, such as CPU load, memory usage, and network bandwidth usage, is first obtained from the host. If the host supports KVM acceleration and has sufficient resources, Vsocket (Virtual Socket) is preferably selected as the target communication connection type. Through Vsocket, an efficient communication channel can be established between the host and the backup virtual machine, supporting high-speed file transfer and complex file system operations. The HTTP server in the backup virtual machine communicates with the host through Vsocket to achieve fast data exchange and meet the needs of high-performance scenarios. However, if the hardware conditions of the host are limited, or the current performance information shows that the host is in a high-load state, Virtio-Port is selected as the target communication connection type. Virtio-Port does not rely on hardware acceleration and can be used in a virtualization environment that does not support KVM (Kernel-based Virtual Machine) acceleration. Therefore, even if the host cannot provide hardware acceleration support, Virtio-Port can still ensure stable communication between the host and the backup virtual machine. This communication method is simple to implement and has a wider range of applications, especially suitable for environments with limited hardware resources.

[0089] Among them, Vsocket is an efficient communication mechanism based on virtualized environment, often used in combination with KVM acceleration, supporting high-speed data transmission and operational flexibility. Virtio-Port is a virtualized communication mechanism that does not rely on hardware acceleration. It is suitable for environments with limited hardware conditions and can run on hosts that do not support KVM acceleration, ensuring effective communication when resources are limited.

[0090] In some complex scenarios, you can even combine Vsocket and Virtio-Port to flexibly switch the communication mechanism according to different virtual machines or different communication tasks to achieve optimal performance and system compatibility.

[0091] In this embodiment, by selecting Vsocket or Virtio-Port according to the performance information of the host machine, it is ensured that it can be flexibly adapted to different hardware environments. Vsocket provides higher performance in scenarios that support hardware acceleration, while Virtio-Port provides wider compatibility under limited hardware conditions, thereby ensuring the communication efficiency and stability of the backup and recovery process.

[0092] In an exemplary embodiment, the above step S201 starts the backup virtual machine in the host machine, and further includes: obtaining a preset virtual machine type; and starting a minimally configured virtual machine corresponding to the preset virtual machine type in the host machine as a backup virtual machine.

[0093] Among them, the preset virtual machine type refers to the pre-defined virtual machine type configuration based on the requirements of the backup task and the resource conditions of the host machine, such as QEMU / KVM virtual machine, VMware virtual machine or virtual machine type of other virtualization platforms. Minimally configured virtual machines refer to virtual machines that only allocate the minimum resources (such as CPU, memory, storage, etc.) required to perform backup and recovery tasks, avoiding occupying too many resources of the host machine, thereby ensuring the stability of the overall system performance.

[0094] Exemplarily, when starting the backup virtual machine, the host first obtains the preset virtual machine type, such as selecting QEMU / KVM or VMware as the virtualization platform. According to the selected virtual machine type, the host starts the corresponding minimally configured virtual machine as the backup virtual machine. The main task of the backup virtual machine is to load the virtual disk file and mount its file system, and these operations do not require a large amount of computing resources. Since loading virtual disk files and mounting file systems are just simple I / O operations and basic system calls, the required CPU and memory resources are very limited. Therefore, the minimally configured virtual machine is sufficient to cope with these tasks, and can minimize the consumption of host resources while ensuring smooth operation. When performing these operations, the backup virtual machine only needs enough resources to handle the identification of the virtual disk, partition mounting and metadata operations. The host starts the virtual machine by allocating minimized resources to ensure that the overall performance of the host will not be significantly affected even under high load conditions. This minimized configuration can meet all requirements in the backup and recovery process without allocating too many resources, thereby improving resource utilization.

[0095] In this embodiment, by obtaining the preset virtual machine type and starting the corresponding minimally configured virtual machine, the resource usage of the host machine is optimized, ensuring that the backup virtual machine can efficiently perform backup and recovery tasks under limited resources. At the same time, the minimally configured virtual machine reduces the resource usage of the host machine, avoids the impact on other business tasks, and improves overall stability and flexibility.

[0096] In another exemplary embodiment, as shown in FIG3 , the present application provides a method for backing up and restoring a virtual machine, the method comprising:

[0097] Step S301 , in response to any operation request for a backup set of a target virtual machine, a host machine obtains a preset virtual machine type, and starts a minimally configured virtual machine corresponding to the preset virtual machine type in the host machine as a backup virtual machine.

[0098] The target virtual machine is the virtual machine to be backed up in the host machine;

[0099] Step S302, obtaining performance information of the host machine, and determining a target communication connection type from preset communication connection types according to the performance information.

[0100] Step S303: Establish a communication connection corresponding to the target communication connection type between the host machine and the backup virtual machine.

[0101] Step S304: Use the virtual disk file in the backup set as a block device of the backup virtual machine, and load the block device into the backup virtual machine.

[0102] Step S305 , after the loading process is completed, in the backup virtual machine, the partition structure in the virtual disk is identified, and the partition type corresponding to each partition in the virtual disk is identified.

[0103] Step S306: In the backup virtual machine, a corresponding mount point directory is created for each partition in the virtual disk.

[0104] Step S307: In the backup virtual machine, according to the partition type and the mount point directory, each partition in the virtual disk is mounted to the corresponding mount point, and the mount point directory is used as the mount information.

[0105] Step S308: Through the communication connection, the host machine obtains the mounting information in the backup virtual machine and displays the mounting information.

[0106] Step S309, in response to the user's request to restore the target file in the mount information, obtain the file data of the target file from the backup virtual machine through the communication connection.

[0107] Step S310, saving the file data to a location specified by the user.

[0108] The target file is a file of the target virtual machine.

[0109] For example, when a user initiates an operation request for a backup set disk file (e.g., requesting to list the files in the backup set), the host will start a minimally configured QEMU virtual machine as a backup virtual machine. The backup virtual machine loads the virtual disk files (such as VMDK, QCOW2, etc.) in the backup set as block devices of the virtual machine. The QEMU configuration file specifies the paths of these virtual disk files to ensure that they are correctly loaded in the virtual machine.

[0110] After the QEMU virtual machine is started, an initialization script will automatically run inside it, which is responsible for detecting and mounting each partition in the virtual disk. The mounting process includes identifying the partition type, mounting the file system, and creating the corresponding mount point directory structure. This process is completed entirely inside the backup virtual machine and will not have any impact on the host machine's operating system, thus avoiding possible kernel crashes or conflicts.

[0111] To achieve efficient communication between the host and the backup virtual machine, vsocket technology is used. vsocket is a communication method in a virtualized environment that can quickly and securely transfer data between the host and the backup virtual machine. After the backup virtual machine is started, the initialization script will also start a vsocket-based HTTP server. The host establishes a connection with the HTTP server through vsocket and sends HTTP requests to obtain the file system information inside the virtual machine.

[0112] When the host requests a backup virtual machine via HTTP, the backup virtual machine returns the mount point information of all the partitions mounted inside it. This information is transmitted back to the host in JSON format or other suitable data formats, and the host can parse this data to obtain the directory structure of each partition in the virtual disk.

[0113] After the user specifies the file or directory to be restored on the host machine, the host machine sends this request to the HTTP server inside the backup virtual machine through an HTTP request. After receiving the request, the HTTP server locates the specified file or directory and transmits its content back to the host machine through an HTTP response. After receiving the data, the host machine saves the file to the storage location specified by the user. The entire transmission process is supported by vsocket, ensuring efficient and secure data transmission.

[0114] In short, the user initiates a request, the host starts the backup VM, and loads the backup set disk file. The initialization script inside the backup VM automatically mounts the disk partition and starts the HTTP server based on vsocket. The host communicates with the backup VM through vsocket, requests the mount point information, and lists the partition contents. The user selects the file to be restored, and the host obtains the file data from the backup VM through HTTP request and saves it to the specified storage location.

[0115] In this embodiment, by mounting the backup set disk in the QEMU virtual machine and performing the file-level recovery operation, the risks of mounting the virtual disk directly in the host kernel are effectively avoided. In the traditional method, the host kernel needs to handle various complex situations in the mounting process, which can easily cause system crashes or instability. However, the present application eliminates the risk of kernel crashes by isolating these operations in the virtual machine, thereby greatly improving the stability of the storage server and ensuring the normal operation of other services. When processing backup set disks containing complex file systems (such as LVM, Logical Volume Manager, Logical Volume Manager), the traditional method may cause name conflicts due to multiple backup sets containing volume groups (VG, Volume Group) with the same name, thereby affecting file recovery operations. The present application successfully isolates the VG name conflict problem between different backup sets by independently managing and mounting the backup set disk in the backup virtual machine. Since the operations in the backup virtual machine will not affect the global namespace of the host machine, there is no need to worry about the complexity caused by the VG conflict, which improves the security and reliability of the system. The use of a vsocket-based HTTP service to implement communication between the host and the virtual machine makes the file-level recovery operation more flexible and efficient. The host machine can obtain the file system information inside the backup virtual machine through a simple HTTP request, and select and restore the specified files on demand, which not only simplifies the operation process, but also speeds up the data transmission speed and improves the efficiency of file recovery. All operations related to the backup set disk are performed in the virtual machine, forming an isolated operating environment, which not only protects the host machine from potential data corruption risks, but also ensures the integrity and security of the backup data. Any operation errors or abnormalities occurring in the backup virtual machine will not affect the host machine, thereby ensuring the security of the entire file-level recovery process. The detection and mounting of disk partitions in the backup virtual machine are completed through automated scripts, and the acquisition of file system information and file transfer processes are simplified by using HTTP services, which greatly simplifies the overall process of file-level recovery. There is no need for users to manually intervene in complex mounting and file operations, which reduces the complexity of operations and improves the user experience.

[0116] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned 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 does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can 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 to be 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.

[0117] Based on the same inventive concept, the embodiment of the present application also provides a virtual machine backup and recovery device for implementing the virtual machine backup and recovery method 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 embodiments of the backup and recovery device for one or more virtual machines provided below can refer to the limitations of the virtual machine backup and recovery method above, and will not be repeated here.

[0118] In an exemplary embodiment, as shown in FIG. 4 , a virtual machine backup and recovery device is provided, including: a virtual machine startup module 401, a block device loading module 402, a mount processing module 403 and a file recovery module 404, wherein:

[0119] The virtual machine startup module 401 is used to start the backup virtual machine in the host machine in response to any operation request for the backup set of the target virtual machine; the target virtual machine is the virtual machine to be backed up in the host machine;

[0120] The block device loading module 402 is used to use the virtual disk file in the backup set as the block device of the backup virtual machine, and load the block device in the backup virtual machine;

[0121] The mounting processing module 403 is used to mount the virtual disk corresponding to the block device in the backup virtual machine after the loading process is completed, so that the backup virtual machine generates mounting information of the virtual disk;

[0122] The file recovery module 404 is used to respond to a recovery request for a target file and recover the target file by backing up the virtual machine and mounting information; the target file is a file of the target virtual machine.

[0123] In one of the embodiments, the mount processing module 403 is also used to identify the partition structure in the virtual disk and the partition type corresponding to each partition in the virtual disk in the backup virtual machine; in the backup virtual machine, a corresponding mount point directory is created for each partition in the virtual disk; in the backup virtual machine, each partition in the virtual disk is mounted to the corresponding mount point according to the partition type and the mount point directory, and the mount point directory is used as the mount information.

[0124] In one of the embodiments, the virtual machine backup and recovery device further includes a communication establishment module for establishing a communication connection between the host machine and the backup virtual machine.

[0125] In one of the embodiments, the backup and recovery device for the virtual machine further includes an information communication module, which is used for the host machine to obtain the mounting information in the backup virtual machine through a communication connection and display the mounting information.

[0126] In one embodiment, the file recovery module 404 is further used to respond to a user's recovery request for a target file in the mount information, obtain file data of the target file from the backup virtual machine through a communication connection, and save the file data to a user-specified location.

[0127] In one of the embodiments, the above-mentioned communication establishment module is also used to obtain performance information of the host machine; determine the target communication connection type from the preset communication connection types based on the performance information; and establish a communication connection corresponding to the target communication connection type between the host machine and the backup virtual machine.

[0128] In one of the embodiments, the virtual machine startup module 401 is further used to obtain a preset virtual machine type; and to start a minimally configured virtual machine corresponding to the preset virtual machine type in the host machine as a backup virtual machine.

[0129] Each module in the backup and recovery device of the virtual machine can be implemented in whole or in part by software, hardware or 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.

[0130] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG5. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. 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 in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a backup and recovery method of a virtual machine is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0131] Those skilled in the art will understand that the structure shown in FIG. 5 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution 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.

[0132] In one 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 method embodiments when executing the computer program.

[0133] In one 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.

[0134] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0135] 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.

[0136] 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.

[0137] 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.

[0138] 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 virtual machine backup and recovery method, characterized in that: The method comprises: In response to any operation request for a backup set of a target virtual machine, starting a backup virtual machine in a host machine; the target virtual machine is a virtual machine to be backed up in the host machine; Using the virtual disk file in the backup set as the block device of the backup virtual machine, and loading the block device in the backup virtual machine; After the loading process is completed, the virtual disk corresponding to the block device is mounted in the backup virtual machine, so that the backup virtual machine generates mounting information of the virtual disk; In response to a recovery request for a target file, the target file is recovered through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

2. The method according to claim 1, characterized in that The step of mounting the virtual disk corresponding to the block device in the backup virtual machine so that the backup virtual machine generates mounting information of the virtual disk includes: In the backup virtual machine, identifying a partition structure in the virtual disk, and identifying a partition type corresponding to each partition in the virtual disk; In the backup virtual machine, creating a corresponding mount point directory for each partition in the virtual disk; In the backup virtual machine, each partition in the virtual disk is mounted to a corresponding mount point according to the partition type and the mount point directory, and the mount point directory is used as the mount information.

3. The method according to claim 1, characterized in that After starting the backup VM in the host, it also includes: Establishing a communication connection between the host machine and the backup virtual machine; Before restoring the target file through the backup virtual machine and the mount information, the method further includes: Through the communication connection, the host machine obtains the mounting information in the backup virtual machine and displays the mounting information.

4. The method according to claim 3, characterized in that The method of restoring the target file by using the backup virtual machine and the mount information in response to the recovery request for the target file includes: In response to a user's request to restore the target file in the mount information, obtaining file data of the target file from the backup virtual machine through the communication connection; The file data is saved to a user-specified location.

5. The method according to claim 3, characterized in that: The establishing of a communication connection between the host machine and the backup virtual machine includes: Obtaining performance information of the host machine; Determining a target communication connection type from preset communication connection types according to the performance information; A communication connection corresponding to the target communication connection type is established between the host machine and the backup virtual machine.

6. The method according to claim 1, characterized in that The step of starting the backup virtual machine in the host machine includes: Get the preset virtual machine type; A minimally configured virtual machine corresponding to the preset virtual machine type is started in the host machine as the backup virtual machine.

7. A virtual machine backup and recovery device, characterized in that: The device comprises: A virtual machine startup module, used to start a backup virtual machine in a host machine in response to any operation request for a backup set of a target virtual machine; the target virtual machine is a virtual machine to be backed up in the host machine; A block device loading module, used to use the virtual disk file in the backup set as the block device of the backup virtual machine, and load the block device in the backup virtual machine; A mounting processing module, used for mounting the virtual disk corresponding to the block device in the backup virtual machine after the loading process is completed, so that the backup virtual machine generates mounting information of the virtual disk; The file recovery module is used to respond to a recovery request for a target file and recover the target file through the backup virtual machine and the mount information; the target file is a file of the target virtual machine.

8. 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 method according to any one of claims 1 to 6 are implemented.

9. 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 method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • A method to implement vmware mounting recovery in a deduplication system

    CN109324931A

  • Systems and methods for providing file level recovery

    CN110795278A

  • Virtual machine file recovery method, system and device and storage medium

    CN111158957A

  • File recovery method and system based on virtual machine backup data

    CN111399984A

  • Minimum configuration method and device for cloud environment of coal preparation plant

    CN116232876A

Cited By

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

    CN120994460A