Backup recovery method and device of virtual machine, computer device, readable storage medium and program product
By starting the backup virtual machine in the host machine, loading and mounting the virtual disk file, and isolating the backup and recovery operations, the problem of poor reliability of virtual machine backup and recovery in the existing technology is solved, and efficient and reliable file-level recovery is achieved.
Patent Information
- Application Number
- CN202411422404.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2044-10-12
AI Technical Summary
Existing file-level recovery methods can easily affect the stability of the storage system when dealing with complex scenarios, resulting in poor reliability of virtual machine backup and recovery.
Start the backup virtual machine in the host machine, load and mount the virtual disk file as a block device, generate mount information through the backup virtual machine, respond to user requests to restore the target file, avoid excessive dependence on the host machine file system, and achieve isolation of backup and recovery operations.
It improves the reliability and efficiency of the backup and recovery process, reduces the impact on the normal business of the host machine, supports on-demand startup, and improves resource utilization and file recovery accuracy.
Smart Images

Figure CN119415317B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a backup and recovery method and device of virtual machine, computer equipment, computer readable storage medium and computer program product. BACKGROUND
[0002] With the rapid development of virtualization technology, more and more enterprises begin to run their core business on virtual machines. Currently, users can quickly extract and restore the required files or directories from the virtual machine backup set without restoring the entire virtual machine image through file-level recovery.
[0003] However, the existing file-level recovery method still has defects when dealing with complex scenarios, which can easily affect the stability of the storage system, thereby causing poor reliability of the backup and recovery of the virtual machine. SUMMARY
[0004] Therefore, it is necessary to provide a backup and recovery method and device of virtual machine, computer equipment, computer readable storage medium and computer program product, which can improve the reliability of the backup and recovery of the virtual machine.
[0005] In a first aspect, the present application provides a backup and recovery method of virtual machine, comprising:
[0006] In response to any operation request on the backup set of the target virtual machine, starting a backup virtual machine in the host machine; the target virtual machine is a virtual machine to be backed up in the host machine;
[0007] The virtual disk file in the backup set is used as a block device of the backup virtual machine, and the block device is loaded 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 the recovery request of the target file, the target file of the target virtual machine is recovered through the backup virtual machine and the mounting information.
[0010] In one embodiment, the mounting process of 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, comprises:
[0011] 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;
[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 using 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, restoring the target file 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 based on 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 further provides a virtual machine backup and recovery device, comprising:
[0029] A virtual machine startup module, configured 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 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 into the backup virtual machine;
[0031] A mounting processing module, configured 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;
[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 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:
[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 into 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 restored 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 into 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 restored 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, comprising a computer program, which, when executed by a processor, implements the following steps:
[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 into 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 restored 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, first, in response to any operation request for the backup set of the target virtual machine, start the backup virtual machine 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 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 host machine's file system, greatly improving the flexibility of operation and data security. 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 mount information for the virtual disk. The mount operation enables the backup virtual machine to identify and access the partitions and file systems in the virtual disk. The generated mount information can provide a clear path and structure for subsequent file operations, ensuring the accuracy and reliability of file recovery. Finally, in response to a recovery request for the target file, the target file is restored through the backup virtual machine and the mount information, wherein the target file is a file of the target virtual machine. The target file is accurately located through the mount information, and the file recovery operation is performed through the backup virtual machine, avoiding the large amount of data copying and redundant operations in traditional recovery methods. In the above method, by starting an independent backup virtual machine on the host machine, the isolation of backup and recovery operations is achieved, significantly improving the stability and resource utilization efficiency of the system. Loading and mounting the virtual disk file in the backup virtual machine avoids excessive dependence on the host machine's 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 following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. 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 any creative work.
[0050] Figure 1 A diagram illustrating an application environment of a virtual machine backup and recovery method according to an embodiment;
[0051] Figure 2 A flowchart of a method for backing up and restoring a virtual machine in one embodiment is shown;
[0052] Figure 3 Schematic diagram of a flow chart of a method for backing up and restoring a virtual machine in another embodiment;
[0053] Figure 4 A structural block diagram of a virtual machine backup and recovery device in one embodiment;
[0054] Figure 5 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0056] The virtual machine backup and recovery method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the backup virtual machine 104 runs in the host machine 102. The data storage system can store 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. In response to any operation request for the backup set of the target virtual machine, the host machine 102 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, Figure 2 As shown, a virtual machine backup and recovery method is provided, which is applied toFigure 1 Taking the host machine 102 in the example as an example, the following steps are included:
[0058] Step S201 : In response to any operation request for a backup set of a target virtual machine, a backup virtual machine is started in a host machine.
[0059] The target virtual machine is the virtual machine to be backed up in the host machine.
[0060] Among them, the host machine is a physical server that runs multiple virtual machines and is responsible for managing the virtualization environment. Virtual machines can be started, stopped, and managed on it.
[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 target VM's backup set (e.g., restoring a file, checking the backup status, performing backup verification, or viewing a specific file or directory), the host machine invokes a virtualization management interface (such as QEMU / KVM, VMware, or Hyper-V) to start the backup VM and allocate resources (e.g., CPU, memory, and storage space) to meet the backup and restore task requirements. Once started, the backup VM runs on the host machine and provides an independent environment for subsequent virtual disk mounting and data restore 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 target VM's data storage format, containing all data generated during the VM's operation, including the operating system, applications, and user data. A block device is an abstract device used to store data. By using a virtual disk file as a block device, the backup VM can directly read and manipulate the data within the virtual disk. Mounting involves connecting the block device to the backup VM, enabling it to access the data structures within the virtual disk and prepare it for mounting and manipulation.
[0065] For example, when the backup VM is started, the host machine selects the target VM's virtual disk file (e.g., VMDK, QCOW2, or other formats) from the backup set and configures it as a block device for the backup VM. The host machine associates the virtual disk file with the backup VM's block device through the virtualization management interface, similar to connecting a physical hard drive to a VM. The backup VM then identifies the block device through a mount operation and treats it as an accessible storage device. Furthermore, the backup VM can access the partitions and file data in the virtual disk through file system operations, preparing for subsequent mount 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 a block device refers to the data storage structure within the block device mounted on the backup VM, typically containing the target VM's partitions, file system, and data. Mounting involves mapping the virtual disk's file system to the backup VM's file system, enabling the backup VM to access the files and directories on the virtual disk through a specified mount point. Mounting information, including the virtual disk's mount path, partition structure, and file system type, is used for subsequent file recovery operations.
[0068] For example, the mount operation can be performed by the backup VM itself through a preconfigured startup script, or by the host machine directly through the virtualization management platform. For an automated solution, upon startup, the backup VM runs an initialization script that automatically detects the loaded virtual disk file. Based on the disk file's partition structure and file system type, it creates a mount point (e.g., / mnt / partition1) for each partition and mounts the corresponding partition into the backup VM's file system. This script loads the appropriate drivers for different file system types (e.g., EXT4, NTFS, etc.) to ensure that the partitions are correctly identified and operated. Alternatively, the host machine can directly control the mount process through the virtualization management interface. The host machine can remotely call the backup VM's management interface to instruct the backup VM to perform the mount operation, or directly execute a command on the host machine to force the backup VM to mount the virtual disk into a specified directory. At this point, the host machine obtains the backup VM's mount information, including the mount point path, partition identifier, and file system type, ensuring that the host machine can always access the current status and structure of the virtual disk. 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 restored by backing up the virtual machine and the mounting information.
[0070] The target file is a file of the target virtual machine.
[0071] The target file refers to the specific file or directory that the user wants to extract and restore from the backup set of the target virtual machine. A 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] For example, a user initiates a file restore request from the host machine, specifying a specific file or directory on the target virtual machine. The backup virtual machine first locates the file system and partition structure on the target virtual machine's virtual disk based on the previously generated mount information. The backup virtual machine then accesses the specific file system on the virtual disk through the mount point and uses the file path in the mount information to precisely locate the user-specified target file. In response to the user's request, the backup virtual machine directly reads the target file from the mounted virtual disk and transfers it back to the host machine, or restores the file to a specified storage path as requested by the user. For example, the backup virtual machine can send the target file to the host machine via a network communication protocol (such as HTTP or FTP) or copy the file to a specified directory on the host machine through file system operations. The host machine can perform multiple restore operations simultaneously, restoring different target files one by one, improving system recovery efficiency. Furthermore, restore operations are not limited to specific file types. The backup virtual machine can use the mount information to accurately read any file type (such as text files or database files) on the target virtual machine, ensuring the broad applicability of the restore 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 host machine's file system, greatly improving operational flexibility and data security. 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 mount information for the virtual disk. The mount operation enables the backup virtual machine to identify and access the partitions and file systems in the virtual disk. The generated mount information can provide a clear path and structure for subsequent file operations, ensuring the accuracy and reliability of file recovery. Finally, in response to a recovery request for the target file, the target file is restored through the backup virtual machine and the mount information. The target file is a file of the target virtual machine. The target file is accurately located through the mount information, and the file recovery operation is performed through the backup virtual machine, avoiding the large amount of data copying and redundant operations in traditional recovery methods. In the above method, by starting an independent backup virtual machine on the host machine, the backup and recovery operations are isolated, significantly improving the stability and resource utilization efficiency of the system. Loading and mounting the virtual disk file in the backup virtual machine avoids excessive dependence on the host machine's 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 within the virtual disk, such as primary partitions and extended partitions. The partition type indicates the file system type of each partition, such as EXT4 and NTFS. The mount point directory is the file system entry created by the backup virtual machine for each partition and is used to access data on the virtual disk.
[0076] For example, after a block device is successfully loaded into the backup VM, the backup VM automatically identifies the partition structure within the virtual disk and loads the appropriate file system driver based on each partition's type. The backup VM then creates a mount point directory for each partition, such as / mnt / partition1 and / mnt / partition2, and mounts each partition to the corresponding mount point directory, allowing the backup VM to access the file system within the virtual disk through these mount points. Mount information includes data such as the mount point directory, partition structure, and partition type, ensuring that the backup VM can accurately locate and access files within the virtual disk.
[0077] This embodiment achieves efficient virtual disk mounting by automatically identifying partition structures and types and creating mount point directories for each partition. This mounting process reduces manual intervention and improves the efficiency of virtual disk operations within the backup virtual machine. The generation of mount information ensures the accuracy and speed of file recovery operations, while reducing 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 step S201 , the process 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 the mount information, the process further includes: the host machine obtains the mount information in the backup virtual machine through the communication connection, and displays the mount information.
[0080] A communication connection is the connection channel established between the host machine and the backup VM for data exchange and control command transmission. It may be based on a dedicated communication protocol (such as vSocket) or a 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 VM in real time, especially obtaining critical mount information during file recovery operations.
[0081] For example, after the backup virtual machine is started, the host machine invokes a communication interface through the virtualization management platform to establish a communication connection between the host machine and the backup virtual machine. This communication connection enables the host machine to monitor the status of the backup virtual machine in real time and send control commands to perform backup and restore operations. Furthermore, the communication connection can be used to transmit mount information generated by the backup virtual machine for use by the host machine during restore operations. This connection mechanism can utilize either a dedicated communication channel provided by the virtual machine manager or a standard network protocol, ensuring flexible and stable communication. After the backup virtual machine mounts the virtual disk, the host machine sends a request to the backup virtual machine via the communication connection to obtain the mount information generated by the backup virtual machine. This mount information typically includes metadata such as the mount point path, partition structure, and file system type, which is used to locate files and directories within the virtual disk. After obtaining this information, the host machine displays it in a user interface, allowing users to browse the virtual disk's directory structure and select target files for restore. Displaying mount information also supports automated restore processes. The system automatically selects appropriate files for restore based on the mount information, ensuring efficient and accurate restore operations.
[0082] In this embodiment, by establishing a communication connection between the host machine and the backup virtual machine, real-time transmission and display of mount information is ensured. Based on the displayed mount information, users or the system can quickly locate and select the target file to be restored, significantly improving the efficiency of file recovery operations. Furthermore, obtaining mount information through the communication connection enables the host machine to monitor the mount status of the backup virtual machine in real time, ensuring a stable and reliable backup and recovery process.
[0083] In an exemplary embodiment, the above-mentioned step S204 recovers the target file through the backup virtual machine and the mount information in response to a recovery request for the target file, and also includes: obtaining the file data of the target file from the backup virtual machine through the communication connection in response to the user's recovery request for the target file in the mount information; and saving the file data to a user-specified location.
[0084] The file data is the content of the target file.
[0085] For example, when a user selects a target file in the mount information on the host machine through a user interface or system command, the host machine sends a file recovery request to the backup virtual machine. Based on the user's selection, the backup virtual machine locates the target file in the mounted virtual disk and reads the file data. Through a communication connection, the backup virtual machine transfers the file data back to the host machine. After receiving the file data, the host machine saves it to the host machine's local storage or other network storage device according to the storage path pre-specified by the user. The host machine can execute multiple file recovery tasks simultaneously, each corresponding to a different file or directory, and each task can specify a different save path, ensuring file recovery flexibility and multi-tasking capabilities.
[0086] In this embodiment, by responding to a user's request to restore the target file in the mount information, the backup VM can quickly and accurately extract the target file's data and transfer it to the host machine via a communication connection. Users can freely select the storage location for the target file, ensuring flexibility and accuracy during the file recovery process. This not only reduces the complexity of data transmission but also optimizes the collaboration between the backup VM and the host machine, improving the efficiency of file recovery operations. This mechanism allows users to quickly restore desired files and perform subsequent operations on them at a designated location, meeting the data recovery needs of various 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, in the communication connection establishment process, first, the current performance information of the host machine is obtained, such as CPU load, memory occupation and network bandwidth usage. If the host machine supports KVM acceleration and the resources are sufficient, the Vsocket (Virtual Socket) is selected as the target communication connection type. Through the Vsocket, an efficient communication channel can be established between the host machine 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 machine through the Vsocket, realizing fast exchange of data and meeting the needs of high-performance scenarios. However, if the hardware conditions of the host machine are limited, or the current performance information shows that the host machine is in a high load state, the Virtio-Port is selected as the target communication connection type. The 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 machine cannot provide hardware acceleration support, the Virtio-Port can still ensure stable communication between the host machine and the backup virtual machine. This communication method is simple to implement and has a wider range of applications, especially in environments with limited hardware resources.
[0089] Among them, Vsocket is an efficient communication mechanism based on virtualization environment, often combined with KVM acceleration, supporting high-speed data transmission and operation flexibility. Virtio-Port is a virtualization communication mechanism that does not rely on hardware acceleration, suitable for environments with limited hardware conditions, and can run on a host machine that does not support KVM acceleration, ensuring effective communication when resources are limited.
[0090] In some complex scenarios, Vsocket and Virtio-Port can even be used in combination, and the communication mechanism can be flexibly switched according to different virtual machines or different communication tasks to achieve the best 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 in different hardware environments. Vsocket provides higher performance in scenarios that support hardware acceleration, while Virtio-Port provides more extensive compatibility in cases where hardware conditions are limited, 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 comprises: obtaining a preset virtual machine type; starting a minimal configuration virtual machine corresponding to the preset virtual machine type in the host machine as the backup virtual machine.
[0093] The preset virtual machine type refers to a predefined virtual machine type configuration according to the requirements of the backup task and the resource condition of the host machine, such as a QEMU / KVM virtual machine, a VMware virtual machine, or a virtual machine type of another virtualization platform. The minimized configuration virtual machine refers to a virtual machine that is only allocated with the minimum resources (such as CPU, memory, storage, etc.) required to perform backup and recovery tasks, thereby avoiding occupying too many resources of the host machine and ensuring the stability of the overall performance of the system.
[0094] For example, when starting the backup virtual machine, the host machine first acquires the preset virtual machine type, for example, selects QEMU / KVM or VMware as the virtualization platform. According to the selected virtual machine type, the host machine starts the minimized configuration virtual machine corresponding to the virtual machine type as the backup virtual machine. The main task of the backup virtual machine is to load the virtual disk file and mount the file system thereof, which does not require a large amount of computing resource. Since loading the virtual disk file and mounting the file system are only simple I / O operations and basic system calls, the required CPU and memory resources are very limited. Therefore, the minimized configuration virtual machine is already sufficient to cope with these tasks, and can minimize the consumption of the resources of the host machine while ensuring the smooth operation. When performing these operations, the backup virtual machine only needs sufficient resources to handle the identification of the virtual disk, partition mounting, and metadata operations. The host machine starts the virtual machine by allocating the minimum resources, thereby ensuring that the overall performance of the host machine will not be significantly affected even in a high-load situation. This minimized configuration can meet all the requirements in the backup and recovery process without allocating too many resources, thereby improving the resource utilization.
[0095] In this embodiment, by acquiring the preset virtual machine type and starting the corresponding minimized configuration virtual machine, the resource usage of the host machine is optimized, and it is ensured that the backup virtual machine can efficiently perform the backup and recovery tasks under limited resources. At the same time, the minimized configuration virtual machine reduces the resource occupation of the host machine, avoids affecting other business tasks, and improves the overall stability and flexibility.
[0096] In another exemplary embodiment, as shown in Figure 3 The present application provides a backup and recovery method of a virtual machine, which comprises:
[0097] In step S301, in response to an arbitrary operation request on a backup set of a target virtual machine, the host machine acquires a preset virtual machine type and starts a minimized configuration virtual machine corresponding to the preset virtual machine type in the host machine as a backup virtual machine.
[0098] The target virtual machine is a virtual machine to be backed up in the host machine.
[0099] Step S302: Acquire performance information of the host machine, and determine a target communication connection type from preset communication connection types based on 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, 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.
[0105] Step S308: The host machine obtains the mount information in the backup virtual machine through the communication connection and displays the mount 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: Save 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's disk files (for example, requesting to list the files in the backup set), the host starts a minimally configured QEMU virtual machine as the backup virtual machine. This backup virtual machine mounts the virtual disk files (such as VMDK and QCOW2) in the backup set as block devices within the virtual machine. The QEMU configuration file specifies the paths to these virtual disk files to ensure they are correctly loaded within the virtual machine.
[0110] When the QEMU virtual machine boots, it automatically runs an initialization script that detects and mounts the partitions in the virtual disk. This mounting process includes identifying the partition type, mounting the file system, and creating the corresponding mount point directory structure. This process is completed entirely within the backup virtual machine, without affecting the host operating system, thus avoiding potential kernel crashes or conflicts.
[0111] To enable efficient communication between the host machine and the backup virtual machine, the vsocket technology is employed. vsocket is a communication method in a virtualized environment that enables fast and secure data transfer between the host machine and the backup virtual machine. After the backup virtual machine is started, the initialization script also starts a vsocket-based HTTP server. The host machine establishes a connection with this HTTP server through vsocket and sends an HTTP request to obtain the file system information inside the virtual machine.
[0112] When the host machine requests the backup virtual machine through HTTP, the backup virtual machine returns the mount point information of all partitions mounted inside it. This information is transmitted back to the host machine in JSON format or other suitable data formats, and the host machine can obtain the directory structure of each partition in the virtual disk by parsing these data.
[0113] After the user specifies the files or directories that need to be restored on the host machine, the host machine sends this requirement to the HTTP server inside the backup virtual machine through an HTTP request. After receiving the request, the HTTP server locates the specified files or directories and transmits their contents back to the host machine through HTTP response. After receiving the data, the host machine saves the files 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 machine starts the backup virtual machine and loads the backup set disk files. The initialization script inside the backup virtual machine automatically mounts the disk partitions and starts a vsocket-based HTTP server. The host machine communicates with the backup virtual machine through vsocket, requests to obtain the mount point information, and lists the partition contents. The user selects the files to be restored, and the host machine obtains the file data from the backup virtual machine through an 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 risk brought by directly mounting the virtual disk in the host kernel is effectively avoided. In the traditional method, the host kernel needs to handle various complex situations during the mounting process, which can easily lead to system crash or instability. By isolating these operations in the virtual machine, the risk of kernel crash is eliminated, thereby greatly improving the stability of the storage server and ensuring the normal operation of other businesses. When processing backup set disks containing complex file systems (such as LVM, Logical Volume Manager), the traditional method may cause name conflicts due to multiple backup sets containing the same volume group (VG, Volume Group), thereby affecting the file recovery operation. By independently managing and mounting the backup set disk in the backup virtual machine, the VG name conflict problem between different backup sets is successfully isolated. Since the operations in the backup virtual machine do not affect the global namespace of the host, there is no need to worry about the complexity brought by VG conflict, improving the security and reliability of the system. The vsocket-based HTTP service is used to realize the communication between the host and the virtual machine, making the file-level recovery operation more flexible and efficient. The host can obtain the file system information inside the backup virtual machine through a simple HTTP request, and select and restore the specified file as needed, not only simplifying the operation process, but also speeding up the data transmission speed and improving 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 from potential data damage risks, but also ensures the integrity and security of the backup data. Any operation error or exception occurring in the backup virtual machine will not affect the host, thereby ensuring the safety of the entire file-level recovery process. Through the automatic script, the disk partition detection and mounting are completed in the backup virtual machine, and the HTTP service is used to simplify the file system information acquisition and file transmission process, greatly simplifying the overall process of file-level recovery. Without manual intervention of complex mounting and file operations, the complexity of the operation is reduced, and the user experience is improved.
[0116] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed 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 portion of steps or stages in other steps.
[0117] Based on the same inventive concept, embodiments of the present application also provide a virtual machine backup and recovery device for implementing the aforementioned virtual machine backup and recovery method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of the embodiments of the backup and recovery device for one or more virtual machines provided below can be found in the aforementioned limitations of the virtual machine backup and recovery method, and will not be further elaborated here.
[0118] In an exemplary embodiment, Figure 4 As shown, 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 into 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 configured 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 mounting processing module 403 is further configured to identify partition structures in the virtual disk and identify partition types corresponding to the partitions in the virtual disk in the backup virtual machine; create mounting point directories corresponding to the partitions in the virtual disk in the backup virtual machine; and mount the partitions in the virtual disk to the corresponding mounting points according to the partition types and the mounting point directories in the backup virtual machine, and take the mounting point directories as the mounting information.
[0124] In one of the embodiments, the backup and recovery apparatus for virtual machine further comprises a communication establishing module configured to establish a communication connection between the host computer and the backup virtual machine.
[0125] In one of the embodiments, the backup and recovery apparatus for virtual machine further comprises an information communication module configured to enable the host computer to acquire the mounting information in the backup virtual machine and display the mounting information through the communication connection.
[0126] In one of the embodiments, the file recovery module 404 is further configured to acquire file data of a target file in the backup virtual machine through the communication connection in response to a recovery request of the target file in the mounting information from a user; and save the file data to a location specified by the user.
[0127] In one of the embodiments, the communication establishing module is further configured to acquire performance information of the host computer; determine a target communication connection type from preset communication connection types according to the performance information; and establish a communication connection corresponding to the target communication connection type between the host computer and the backup virtual machine.
[0128] In one of the embodiments, the virtual machine starting module 401 is further configured to acquire a preset virtual machine type; and start a minimal configuration virtual machine corresponding to the preset virtual machine type in the host computer as the backup virtual machine.
[0129] The modules in the backup and recovery apparatus for virtual machine can be realized by software, hardware, or a combination thereof. The modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in the computer device in software form, so as to be called and executed by a processor to perform operations corresponding to the modules.
[0130] In one of the embodiments, a computer device is provided, which can be a terminal. An internal structure diagram of the computer device can be as shown in Figure 5As shown. The computer device includes a processor, memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and 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 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 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 external devices. The communication interface of the computer device is used to communicate with external terminals via wired or wireless means, and the wireless means can be implemented via Wi-Fi, a mobile cellular network, near-field communication (NFC), or other technologies. When executed by the processor, the computer program implements a method for backing up and restoring a virtual machine. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.
[0131] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the 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 component arrangement.
[0132] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, 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] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. 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. In particular, any reference to memory, database, or other media used in the embodiments provided in this 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. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.
[0137] The technical features of the above embodiments can be combined arbitrarily. In order 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 merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended 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, a preset virtual machine type is obtained; a minimally configured virtual machine corresponding to the preset virtual machine type is started in a host machine as a backup virtual machine; the target virtual machine is the virtual machine to be backed up in the host machine; the backup virtual machine is a virtual machine used to perform backup and recovery tasks; the minimally configured virtual machine is a virtual machine allocated only the minimum resources required to perform backup and recovery tasks; The virtual disk file in the backup set is used as a block device of the backup virtual machine, and the block device is loaded into the backup virtual machine; the virtual disk file is a data storage format of the target virtual machine, and contains all data generated during the operation of the target virtual machine, including the operating system, application programs and user data; 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 restored by using the backup virtual machine and the mount information; the target file is a file of the target virtual machine; After starting the backup VM on the host machine, the following steps are also included: Obtaining performance information of the host machine; Determining a target communication connection type from preset communication connection types based on the performance information; Establishing a communication connection corresponding to the target communication connection type between the host machine and the backup virtual machine; Before restoring the target file using 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.
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 The step of restoring the target file by using the backup virtual machine and the mount information in response to the restore 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.
4. The method according to claim 1, wherein The virtual disk corresponding to the block device refers to a data storage structure in the block device loaded by the backup virtual machine.
5. A virtual machine backup and recovery device, characterized in that: The device comprises: A virtual machine startup module is configured to, in response to any operation request for a backup set of a target virtual machine, obtain a preset virtual machine type; and start a minimally configured virtual machine corresponding to the preset virtual machine type in a host machine as a backup virtual machine; the target virtual machine is the virtual machine to be backed up in the host machine; the backup virtual machine is a virtual machine used to perform backup and recovery tasks; the minimally configured virtual machine is a virtual machine allocated only the minimum resources required to perform backup and recovery tasks; A block device loading module is configured to 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; the virtual disk file is a data storage format for the target virtual machine and contains all data generated during the operation of the target virtual machine, including the operating system, application programs, and user data; A mounting processing module, configured 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; A file recovery module, configured to respond to a recovery request for a target file and recover the target file by using the backup virtual machine and the mount information; the target file is a file of the target virtual machine; The device further includes a communication establishment module for 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; The device further includes an information communication module, which is configured to enable the host machine to obtain the mounting information in the backup virtual machine through the communication connection and to display the mounting information.
6. The device according to claim 5, characterized in that The mount processing module 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; create a corresponding mount point directory for each partition in the virtual disk in the backup virtual machine; in the backup virtual machine, mount each partition in the virtual disk to the corresponding mount point according to the partition type and the mount point directory, and use the mount point directory as the mount information.
7. The device according to claim 5, characterized in that The file recovery module is further configured to respond to a user's recovery request for the target file in the mount information, obtain file data of the target file from the backup virtual machine through the communication connection, and save the file data to a user-specified location.
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 4 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 4 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 4 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
File recovery method and system based on virtual machine backup data
CN111399984A
Information providing method and device applied to server of edge computing cluster
CN117931097A
Systems and methods for selectively restoring files from virtual machine backup images
US11068353B1