Instantaneous recovery method for Hyper-V virtual machine based on ISCSI
By using the iSCSI protocol and differential mirroring technology, the problems of slow virtual machine recovery and data corruption are solved, enabling fast and secure virtual machine recovery in small and medium-sized enterprise environments, and is suitable for a wide range of enterprise IT infrastructures.
Patent Information
- Application Number
- CN202511800013.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-02
- Publication Date
- 2026-02-27
AI Technical Summary
Existing virtual machine recovery technologies are slow in large-volume data transfers and rely on Active Directory domain environments, making them unsuitable for small and medium-sized enterprises and posing a risk of contamination of the original backup data.
The backup data is stored as an image file using the iSCSI protocol. A differential image file is created and published as a target through the iSCSI service, which is then directly mounted to the target Hyper-V host. Combined with virtual machine snapshot technology, this ensures the security and integrity of the backup data.
It enables instantaneous recovery of virtual machines within seconds or minutes in a normal local area network environment, avoids data corruption, is suitable for a wide range of enterprise environments, and provides flexible data recovery capabilities.
Smart Images

Figure CN121579141A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a Hyper-V virtual machine instant recovery method based on ISCSI. BACKGROUND
[0002] With the increasing maturity and popularity of virtualization technology, virtual machines represented by Microsoft Hyper-V have become the core component of enterprise IT infrastructure, which carries key business applications and services, and its continuous availability and instant recovery capability is directly related to the normal operation of the enterprise; therefore, the data backup and recovery technology of virtual machine has always been the focus of industry attention and research.
[0003] Currently, there are many virtual machine backup and recovery solutions on the market, and the typical process is usually as follows: first, create a snapshot of the running virtual machine, then transfer the data in the snapshot (including virtual disk files, configuration files, etc.) to a dedicated backup storage server through the network to form a backup set; when the virtual machine in the production environment fails, data is lost or the system crashes, the recovery process is performed in reverse: the recovery software copies the data files in the backup set from the backup server to the production server or the designated recovery host, and then registers and starts the virtual machine based on these files.
[0004] However, this traditional recovery mode exposes significant performance bottlenecks and operational limitations in actual application. The primary problem is low recovery efficiency, as the virtual machine disk file (VHD / VHDX) is large in size, often hundreds of GB or even TB, and during the recovery process, the entire backup file needs to be transferred through the network. In a typical gigabit or limited bandwidth LAN environment, this data copying stage will consume a lot of time, resulting in a long recovery process; for business systems that need to be recovered urgently, waiting for several hours or even days is unacceptable, which seriously violates the recovery time objective (RTO) requirement of business continuity.
[0005] Secondly, existing solutions lack flexibility in recovery mode, that is, in some advanced solutions in the domain environment, although "instant recovery" can be achieved by directly mounting remote backup files, this usually depends on specific sharing protocols and domain permissions, making this technology severely limited in the domain environment; for many small and medium-sized enterprises that do not deploy Active Directory domains, this technology is not applicable; more importantly, directly mounting the original backup file for recovery means that all runtime write operations of the virtual machine will directly affect the backup data, which poses a huge risk of polluting the original backup set, destroying the integrity and security of the backup data, and causing hidden dangers for subsequent data tracing and recovery.
[0006] Therefore, we propose a method that can realize the instantaneous recovery of virtual machines in seconds or minutes without large-scale data replication in a general LAN environment, and ensure the security of the original backup data. SUMMARY
[0007] The purpose of the present application is to provide an ISCSI-based Hyper-V virtual machine instantaneous recovery method, which solves the problems of slow recovery speed caused by traditional large-capacity data transmission, dependence on domain environment, and difficulty in effectively protecting original backup data from being changed when pursuing instantaneous recovery.
[0008] The present application is implemented by the following technical solutions: An ISCSI-based Hyper-V virtual machine instantaneous recovery method, specifically comprising: Prepare backup data and store it in the form of an image file, and each image file corresponds to a backup point; Deploy an ISCSI (Internet Small Computer System Interface) service; Select a restore point corresponding to the backup point, and create a differential image file based on the selected restore point; Publish the differential image file as an ISCSI target through the ISCSI service; Connect and mount the ISCSI target on the target Hyper-V host; Create an empty virtual machine and attach the virtual disk file in the ISCSI target; Create a virtual machine snapshot and start the virtual machine.
[0009] Further, the backup data includes full backup, incremental backup, and differential backup.
[0010] Further, the image file contains the disk file, snapshot file, and configuration file of the virtual machine.
[0011] Further, the creation method of the differential image file includes: Call the Windows API CreateVirtualDisk, or use the diskpart tool to execute the create vdisk command.
[0012] Further, the ISCSI service is modified based on open source software into a Windows service, and receives the creation and deletion requests of the ISCSI target through Web API or RPC.
[0013] Further, the Web API is a POST request, receives JSON parameters containing differential image file path, task ID, shared path and authentication information, and returns an ISCSI target name.
[0014] Further, the connecting and mounting the ISCSI target on the target Hyper-V host includes the following steps: adding an ISCSI target portal; retrieving and connecting the ISCSI target; obtaining a disk number and mounting to a local directory.
[0015] Further, the creating an empty virtual machine and attaching the virtual disk file in the ISCSI target includes the following steps: locally creating a symbolic link pointing to the disk file in the ISCSI mounting directory; attaching the disk file pointed by the symbolic link to the empty virtual machine.
[0016] Further, the method further includes, after starting the virtual machine, migrating disk data of the selected restore point from the backup server to the Hyper-V host in the background.
[0017] A computer readable storage medium, which stores a computer program, when the program is executed by a processor, implements the above-mentioned ISCSI-based instant recovery of Hyper-V virtual machine method.
[0018] The technical scheme of the present application has at least the following advantages and beneficial effects: The present application discloses an ISCSI-based Hyper-V virtual machine instant recovery method, which mounts backup data on a backup server to a target Hyper-V host through an ISCSI protocol after differential image processing, and uses it as a local disk.
[0019] In addition, by introducing a differential image file as an intermediate layer for recovery, all virtual machine runtime write operations are directed to the differential disk, while the original backup image file is always in read-only state.
[0020] Furthermore, communication based on the standard iSCSI protocol and network sharing eliminates the need for an Active Directory domain environment, enabling seamless deployment and use in ordinary LAN environments, including a wide range of small and medium-sized enterprises, greatly expanding the applicable scenarios for the technology.
[0021] Furthermore, by being compatible with mirror storage modes for full backups, incremental backups, and differential backups, and by intelligently handling their dependencies, users can choose any valid restore point for recovery, providing refined data recovery capabilities while ensuring recovery speed. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of a Hyper-V virtual machine instantaneous recovery method based on ISCSI according to the present invention; Figure 2 This is a schematic diagram of the steps for connecting to and mounting the ISCSI target on the target Hyper-V host according to the present invention; Figure 3 This is a schematic diagram of the electronic device structure of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0024] Example 1 like Figures 1-2 The method shown is a Hyper-V virtual machine instantaneous recovery method based on iSCSI, which specifically includes: Prepare backup data and store it in the form of image files, with each image file corresponding to a backup point; the backup data includes full backups, incremental backups and differential backups, and the backup data is organized and stored in units of virtual machines; In addition, the image file contains the virtual machine's disk file, snapshot file, and configuration file.
[0025] Deploy iSCSI service; This allows the iSCSI target to be used as a local disk on a remote Hyper-V host. As a result, even if the Hyper-V host that needs to be restored cannot directly access the backup storage server, data access can still be achieved through the iSCSI service using this solution. Furthermore, since Windows 10 lacks an iSCSI service, and the iSCSI service on Windows Server does not support remote file sharing, we used an open-source iSCSI service software, modified it to run as a Windows Service, and used an HTTP-based Web API or RPC to receive requests for adding and deleting iSCSI targets. It is important to note that the Web API uses a POST request, which receives JSON parameters containing the path to the differential image file, the task ID, the shared path, and authentication information, and returns the iSCSI target name.
[0026] Select the restore point corresponding to the backup point, and create a differential image file based on the selected restore point; Backup points and restore points are corresponding entities. The difference between them is that backup points are like archive files, while restore points are selected when restoration is needed. Since backups use image storage, it is not necessary to transfer the full backup corresponding to the selected incremental or differential backup. However, it is essential to ensure that the selected restore point can find the complete backup image file it depends on. Furthermore, backup sets can be stored on the local machine where the recovery software is located or shared remotely. The purpose of creating differential image files is to protect the original backup files from being tampered with and shared by multiple tasks. This file is stored on the host machine where the recovery software is located. In addition, the image file here is a "chained" storage structure. It is created based on a parent image, which is the selected restore point backup file. Its initial size is very small. All new write and modification operations on the virtual disk will be redirected and recorded in this differential image file, while the parent image file always remains in a read-only state. Since the original backup file is not written, the purity and security of the backup set are ensured. It can be reused by other recovery tasks or future recovery operations. Multiple recovery tasks can create their own independent differential image files based on the same original backup for recovery without interfering with each other. Furthermore, creating a differential image file is a local metadata operation, which is extremely fast and does not require copying large amounts of original data, thus creating conditions for "instant recovery".
[0027] In addition, differential image files can be created in the following ways: Here is a partial code example of calling the Windows API CreateVirtualDisk: [DllImport("virtdisk.dll", CharSet = CharSet.Unicode)] public static extern int CreateVirtualDisk( ref VIRTUAL_STORAGE_TYPE VirtualStorageType, string Path, VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask, IntPtr SecurityDescriptor, CREATE_VIRTUAL_DISK_FLAG Flags, int ProviderSpecificFlags, ref CREATE_VIRTUAL_DISK_PARAMETERS Parameters, IntPtr Overlapped, out IntPtr Handle); The parameters are as follows: Path passes the filename of the differential image to be created, and Parameters specifies the filename of the selected restore point image. Alternatively, you can use the diskpart tool to execute the create vdisk command. The specific steps are as follows: Run cmd.exe, and then enter the following commands in sequence: DiskPart Create vdisk file="differential image file name" parent="selected restore point image file name" Exit.
[0028] The differential image file is published as an ISCSI target via the ISCSI service; This step involves receiving requests and creating a web API interface for the iSCSI target within the iSCSI service, as detailed in the table below: Table 1. Web API Interface Diagram
[0029] The iSCSI server works by virtualizing local storage, in this case, the differential image file, into "raw" block devices and publishing them as "targets" over the network. The Hyper-V host acts as an iSCSI initiator, connecting to this target over the network, and the operating system recognizes it as a local physical disk. In this way, publishing the differential image file as an iSCSI target via the iSCSI service skips the process of transferring hundreds of gigabytes or even terabytes of data from the backup server to the Hyper-V host. Recovery speed is no longer limited by network bandwidth and file size, but depends on the speed of establishing the iSCSI connection, achieving "second-level" or "minute-level" recovery. Furthermore, backup data can be stored anywhere on the network (such as remote sharing), as long as the iSCSI service can access it. The Hyper-V host does not need to directly access the shared path of the backup storage; it only needs the standard iSCSI protocol to connect. This makes the solution highly versatile in ordinary LAN environments.
[0030] In addition, since the iSCSI target needs to run for a long time after the instantaneous recovery, including the need to automatically remount after the host where the recovery software is located restarts, it is necessary to transmit the remote sharing account and password to facilitate the reconnection to the sharing after the iSCSI host restarts.
[0031] Connect to and mount the iSCSI target on the target Hyper-V host; This operation is performed on the Hyper-V host where the virtual machine will be momentarily mounted. An iSCSI client must be installed; Windows systems typically have an iSCSI client installed by default, and the corresponding service's display name is Microsoft iSCSIInitiator Service. If the service is not running, start it first. The specific steps include: Add an iSCSI target portal, specifically as follows: Add using PowerShell commands: New-ISCSITargetPortal –TargetPortalAddress xxx.xxx.xxx.xxx –TargetPortalPortNumer 3260; Where xxx.xxx.xxx.xxx is the IP address of the iSCSI server; TargetPortalPortNume is the connection port number, which is 3260 by default.
[0032] If the iSCSI service is deployed on Windows Server, since Windows Server comes with its own iSCSI service and uses port 3260 by default, for the open-source iSCSI service to function properly, either the built-in iSCSI service on Windows Server must be disabled, or the listening port must be changed, for example, to 3261. In this case, the parameter –TargetPortalPortNumer of the method New-ISCSITargetPortal needs to be modified to 3261. Retrieve and connect to the iSCSI target, specifically: Using PowerShell commands get-ISCSItarget | where-object NodeAddress -eq '{targetIqn}' Where {targetIqn} is the ISCSI target name obtained during creation; After a new iSCSI target is retrieved, it is in a disconnected state by default. Connect using PowerShell commands. Connect-ISCSITarget -NodeAddress "{targetIqn}" Where {targetIqn} is the ISCSI target name obtained during creation; After successfully connecting to the iSCSI target, a disk without a drive letter will appear in Windows Disk Management. You need to obtain its Disk Number. By obtaining the disk list and then, based on the DiskNumber in the disk list, looking up the targetIqn corresponding to each diskNumber, a partial code example is shown below: Get a list of disks: get-disk Get the targetIqn corresponding to the disk: get-disk -number {diskNumber} | get-ISCSIsession Method: The return information of get-ISCSIsession contains the targetIqn information. If the returned targetIqn is the same as the name of the ISCSI target to be connected, then the corresponding diskNumber is found.
[0033] Obtain the disk number and mount it to the local directory, specifically as follows: First, on the Hyper-V host where the virtual machine needs to be instantaneously mounted, create a folder for instantaneous virtual machine recovery. Then, create a subfolder named "mnt" within this folder. This subfolder will be used to invoke PowerShell commands to map the found diskNumber to the "mnt" directory. A partial code example is shown below: Get-Partition -DiskNumber {diskNumber} -PartitionNumber 1 | Add-PartitionAccessPath -AccessPath '{mntDir}' If the execution is successful, the contents of the iSCSI target can be viewed in the mnt directory.
[0034] Although disks mounted via iSCSI are treated as local disks at the system level, their physical data is still stored remotely over the network. If the VHDX file under the mount point (mnt directory) is directly attached to the virtual machine, all I / O operations generated by the virtual machine during runtime (including new data added when creating snapshots) need to be written to the iSCSI server's disk over the network, which will become a performance bottleneck. Therefore, by creating symbolic links on the Hyper-V host to point the virtual machine configuration to a local "link file," which actually points to the real disk file in the iSCSI target, runtime I / O performance can be improved. When Hyper-V creates a snapshot or writes to the virtual machine, the new AVHDX differential image file is generated on the local disk where the symbolic link is located, instead of being written to the remote iSCSI target over the network. This greatly reduces the impact of network latency on virtual machine performance and ensures the smooth operation of the virtual machine after recovery. At the same time, it also achieves the separation of data paths, separating configuration information pointing to remote data through symbolic links and runtime data stored locally. This separation is key to balancing instant recovery speed and subsequent user experience.
[0035] Create an empty virtual machine and attach the virtual disk file from the iSCSI target; In addition, the specific steps include: Create a symbolic link locally pointing to the disk file in the iSCSI mount directory; This involves creating a directory named "disk" at the same level as the "mnt" subdirectory within the created instant recovery directory; then retrieving all "vhd" or "vhdx" files from the "mnt\virtual Hard Disk" directory and creating a link for each of these files to the "disk" directory. The purpose of this step is to ensure that after creating a snapshot, the snapshot file is generated on the Hyper-V host disk where the virtual machine needs to be instantaneously mounted. Otherwise, it would be generated directly in the "mnt\virtual Hard Disk" directory, where the data actually resides on the iSCSI server's disk files, which would affect the virtual machine's write speed after booting.
[0036] The following is part of the code for creating a link: The command `cmd.exe / c mklink "Instant Recovery Directory\disk\xxx.vhdx" "Instant Recovery Directory\mnt\Virtual Hard Disks\xxx.vhdx` is executed. Append the disk file pointed to by the symbolic link to the empty virtual machine; This assigns the first disk file in the disk directory to the newly created virtual machine; if there are multiple disks, the addition operation is performed multiple times. A partial code example is shown below: Add-VM HardDiskDrive -VmName 'Name of the virtual machine to be instantaneously restored' -ControllerType 'IDE' -ControllerNumber 0 -ControllerLocation 0 -Path 'Disk file path' The 'disk file path' format is as follows: Instant Recovery Directory\disk\xxx.vhdx.
[0037] Additionally, the following are some of the instructions for creating an empty virtual machine: New-VM-Generation 1 -MemoryStartupBytes<memory size unit: bytes> -Name 'Instantaneous recovery virtual machine name'.
[0038] Start the virtual machine after creating a virtual machine snapshot; Here is a code example for creating a snapshot: $vm=GET-VM -ID 'Virtual Machine ID';Checkpoint-VM -VM $vm -SnapshotName 'Snapshot Name' -Passthru The purpose is to ensure that even if unexpected events occur during subsequent operations or when the user is using the restored virtual machine, the virtual machine can be quickly rolled back to this initial snapshot, ensuring that the virtual machine state instantly returns to the pure state it was in when it was just restored, without affecting the differential image that serves as the parent disk, and without affecting the original backup.
[0039] The virtual machine ID is returned after an empty virtual machine is created.
[0040] Example 2 As attached Figure 3 An electronic device shown includes: Processor, memory, communication interface; The memory is used to store the executable instructions of the processor; The processor is configured to execute the above-described method for instantaneous recovery of a Hyper-V virtual machine based on ISCSI by executing the executable instructions.
[0041] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above for instantaneous recovery of a Hyper-V virtual machine based on iSCSI.
[0042] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for instantaneous recovery of Hyper-V virtual machines based on iSCSI, characterized in that, Specifically, it includes: Prepare backup data and store it in the form of image files, with each image file corresponding to a backup point; Deploy iSCSI service; Select the restore point corresponding to the backup point, and create a differential image file based on the selected restore point; The differential image file is published as an ISCSI target via the ISCSI service; Connect to and mount the iSCSI target on the target Hyper-V host; Create an empty virtual machine and attach the virtual disk file from the iSCSI target; Start the virtual machine after creating a virtual machine snapshot.
2. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The backup data includes full backups, incremental backups, and differential backups.
3. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The image file contains the virtual machine's disk file, snapshot file, and configuration file.
4. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The methods for creating the differential image file include: Call the Windows API CreateVirtualDisk, or use the diskpart tool to execute the create vdisk command.
5. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The iSCSI service is based on open-source software and has been modified into a Windows service. It receives creation and deletion requests for iSCSI targets via Web API or RPC.
6. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 5, characterized in that: The Web API is a POST request that receives JSON parameters containing the differential image file path, task ID, shared path, and authentication information, and returns the iSCSI target name.
7. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The specific steps for connecting to and mounting the iSCSI target on the target Hyper-V host include: Add an iSCSI target portal; Retrieve and connect to the iSCSI target; Obtain the disk number and mount it to the local directory.
8. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: The specific steps for creating an empty virtual machine and attaching the virtual disk file from the iSCSI target include: Create a symbolic link locally pointing to the disk file in the iSCSI mount directory; Attach the disk file that the symbolic link points to to the empty virtual machine.
9. The method for instantaneous recovery of Hyper-V virtual machines based on iSCSI according to claim 1, characterized in that: This method also includes migrating the disk data of the selected restore point from the backup server to the Hyper-V host in the background after the virtual machine starts.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method for instantaneous recovery of a Hyper-V virtual machine based on ISCSI as described in any one of claims 1 to 9.