Method for backing up VMware virtual machine

By enabling block tracking and snapshot functions, saving virtual machine configuration information, and using NFS services to implement virtual machine backup, the problems of slow backup data recovery speed and incremental backup failure in the existing technology are solved, and backup efficiency and system availability are improved.

CN119645727APending Publication Date: 2025-03-18成都傲梅科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411724487.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

When recovering data, existing VMware virtual machine backup products have a slow recovery speed due to large backup data files, and cannot achieve instantaneous recovery. Most products cannot directly create the vmfs format files required by VMware ESXi on NTFS and Ext file systems, resulting in incremental backup failure.

Method used

By enabling block tracking and snapshots, only modify data since the last backup is recorded, reducing backup time and storage resources. Save the complete configuration information of the source virtual machine to ensure the integrity and consistency of the backup files. Create backup disks and mount them to ESXi with NFS temporary directories and NFS services, enabling flexible storage options and automated backup management processes.

Benefits of technology

Improve backup efficiency, ensure the integrity and consistency of backup files, realize flexible storage options and automated backup management processes, ensure rapid and reliable recovery of virtual machine state during disaster recovery, reduce business interruption time, and improve system availability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645727A_ABST
    Figure CN119645727A_ABST
Patent Text Reader

Abstract

The invention discloses a VMware virtual machine backup method. The method comprises the following steps: step S1, starting source virtual machine block tracking; s2, creating a snapshot by the source virtual machine; s3, storing complete configuration information of the source virtual machine; s4, judging whether the backup is locally carried out or not; s5, judging whether backup is carried out to the NFS or not; S6, creating an MKlink from a complete backup directory to a temporary directory of the NFS; step S7, starting an NFS service; step S8, mounting the NFS to the EsXi; step S9, creating a backup disk in the data; and S10, calling the SDK to read and write disk data, and completing backup. According to the method and the device, the complete configuration information of the source virtual machine is stored in the backup process, so that the integrity and the consistency of the backup file are ensured, and the state of the virtual machine can be seamlessly recovered during recovery. By creating the NFS temporary directory and starting the NFS service, the backup management process is simplified. And the state of the virtual machine can be quickly and reliably recovered during disaster recovery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of virtual machine data backup, and in particular relates to a VMware virtual machine backup method. Background Art

[0002] Since the birth of VMware virtual technology, its products have been well received by users, and there are many products on the market for virtual machine backup and recovery. However, from the perspective of data recovery efficiency using these products, the recovery speed is slow due to the large size of the backup data files, and most of the time is spent on the data copy and transfer stage, and some may take several hours or even 1-2 days.

[0003] Therefore, there is a need for both backup and instant recovery based on the backup. Since most software providers use their own file formats to store data during backup, rather than the standard VMDK files required by VMware ESXi, the backup data must be re-transcribed during recovery. If the backup file is too large, the transcription time is very long, which cannot meet the requirements of instant recovery.

[0004] Another problem is that since most VMware backup products on the market are developed using the VDDK software package, this SDK cannot directly create the vmfs format files required by VMware ESXi on the NTFS and Ext file systems. Even if it can be created, it will create backup files of equal size on the operating system based on the pre-allocated space of the disk, rather than allocating space based on the actual size of the data. The full backup and incremental backup are the same size, which defeats the purpose of incremental backup. Even if the backup disk file can be created according to the actual data size of the incremental backup, it can only be quickly restored on VMware Workstation, not instantly restored on VMware ESXi, which again loses the instantaneous restore function. Summary of the invention

[0005] The purpose of the present invention is to provide a method for backing up VMware virtual machines to solve the problem raised in the background technology that most software providers use their own file formats to store data during backup, which is not the standard VMDK file required by VMware ESXi. Therefore, the backup data must be re-transcribed during recovery. If the backup file is too large, the transcription time is very long.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0007] A method for backing up a VMware virtual machine includes the following steps:

[0008] Step S1, start source virtual machine block tracking; used to record the modified data of modified disk blocks;

[0009] Step S2, the source virtual machine creates a snapshot; after the snapshot is generated, the snapshot disk file is used to record all modifications;

[0010] Step S3, save the complete configuration information of the source virtual machine; the saved configuration is used for the next backup, and the changeID information of each disk in the configuration is obtained, and the corresponding block modification data in step S1 can be queried using the changeID;

[0011] Step S4, determine whether to back up locally; if yes, jump to step S10; if not, go to step S5;

[0012] Step S5, determining whether to back up to NFS, if yes, directly starting NFS, if not, creating a temporary NFS directory;

[0013] Step S6, creating an MKlink from the complete backup directory to the NFS temporary directory;

[0014] Step S7, start the NFS service; by passing the NFS temporary directory address created in step S5 as a startup parameter to the NFS software, the NFS software will monitor this directory internally;

[0015] Step S8, mount NFS to EsXi; register the NFS service as datastore on the ESXi host to be backed up;

[0016] Step S9, creating a backup disk in the datastore;

[0017] Step S10, calling the SDK to read and write disk data, downloading the configuration file of the backup virtual machine to the backup directory to complete the backup.

[0018] According to the above technical solution, in step S3, the complete configuration information of the source virtual machine is saved by using the RetrievePropertiesEx method of the VMware vSphere API to query all the configuration information of the source virtual machine and save it separately in the backup directory in the form of a file.

[0019] According to the above technical solution, in step S6, creating an MKlink from the backup directory to the NFS temporary directory is specifically: mapping the parent directory of the complete backup directory to the NFS temporary directory created in step S5 by means of a soft link.

[0020] According to the above technical solution, under Windows, the following command is used to create a soft link: MKLink / D "soft link directory address" "real directory address".

[0021] According to the above technical solution, NFS is mounted to EsXi using VMware vSphere API or SSH instructions.

[0022] According to the above technical solution, using VMware vSphere API specifically involves: using the CreateNasDatastore method in VMware vSphere APIAPI, and completing the mounting after specifying the corresponding parameters.

[0023] According to the above technical solution, the parameters include: NFS server IP, NFS temporary directory created in step S5, datastore name and access mode.

[0024] According to the above technical solution, the specific steps of using SSH command for mounting are: start the ESXi SSH service and use the background command in the format of:

[0025] vim-cmd hostsvc / datastore / nas_create [datastoreName] [NFS version number] [NFS monitoring folder] [Is it read-only] [NFS server ip].

[0026] According to the above technical solution, in step S9, creating a backup disk in the datastore is specifically as follows:

[0027] Use the CreateVirtualDisk_Task function of the VMware vSphere API to create an empty disk file in the NFS temporary directory.

[0028] According to the above technical solution, in step S10, calling SDK to read and write disk data is specifically as follows: creating a snapshot on the source virtual machine, then using the VixDiskLib_Open function to open the disk file in the file path format of datastore, using the VixDiskLib_Read function to read the source disk file data, and using the VixDiskLib_Write function to write the data to the vmdk file in the backup directory.

[0029] Compared with the prior art, the present invention has the following beneficial effects:

[0030] In the present invention, by enabling block tracking and snapshot functions, the backup process only records the modified data since the last backup, reducing the time and storage resources required for backup and improving backup efficiency. The complete configuration information of the source virtual machine is saved during the backup process, ensuring the integrity and consistency of the backup file, and facilitating the seamless restoration of the state of the virtual machine during recovery. The method in the present invention allows the backup to be saved to a local or network file system (NFS), providing flexible storage options that can adapt to different environments and needs. By creating an NFS temporary directory and starting the NFS service, the backup management process is simplified, making the backup process more automated and easy to maintain. It ensures that the virtual machine state can be restored quickly and reliably during disaster recovery, reducing business interruption time and improving system availability. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 This is a flowchart of the complete backup of a virtual machine of the present invention;

[0032] Figure 2 This is a flowchart of the incremental backup of a virtual machine according to the present invention. DETAILED DESCRIPTION

[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0034] Embodiment 1

[0035] like Figure 1 As shown, a method for backing up a VMware virtual machine includes the following steps:

[0036] Step S1, start source virtual machine block tracking; used to record the modified data of modified disk blocks;

[0037] Step S2, the source virtual machine creates a snapshot; after the snapshot is generated, the snapshot disk file is used to record all modifications;

[0038] Step S3, save the complete configuration information of the source virtual machine; the saved configuration is used for the next backup, and the changeID information of each disk in the configuration is obtained, and the corresponding block modification data in step S1 can be queried using the changeID;

[0039] Step S4, determine whether to back up locally; if yes, jump to step S10; if not, go to step S5;

[0040] Step S5, determining whether to back up to NFS, if yes, directly starting NFS, if not, creating a temporary NFS directory;

[0041] Step S6, creating an MKlink from the complete backup directory to the NFS temporary directory;

[0042] Step S7, start the NFS service; by passing the NFS temporary directory address created in step S5 as a startup parameter to the NFS software, the NFS software will monitor this directory internally;

[0043] Step S8, mount NFS to EsXi; register the NFS service as datastore on the ESXi host to be backed up;

[0044] Step S9, creating a backup disk in the datastore;

[0045] Step S10, calling the SDK to read and write disk data, downloading the configuration file of the backup virtual machine to the backup directory to complete the backup.

[0046] In the present invention, by enabling block tracking and snapshot functions, the backup process only records the modified data since the last backup, reducing the time and storage resources required for backup and improving backup efficiency. The complete configuration information of the source virtual machine is saved during the backup process, ensuring the integrity and consistency of the backup file, and facilitating the seamless restoration of the state of the virtual machine during recovery. The method in the present invention allows the backup to be saved to a local or network file system (NFS), providing flexible storage options that can adapt to different environments and needs. By creating an NFS temporary directory and starting the NFS service, the backup management process is simplified, making the backup process more automated and easy to maintain. It ensures that the virtual machine state can be restored quickly and reliably during disaster recovery, reducing business interruption time and improving system availability.

[0047] Embodiment 2

[0048] This embodiment provides a specific implementation method:

[0049] The process of achieving a full backup is as follows:

[0050] 1. Enable the source virtual machine block tracking function. After enabling this function, ESXi will record which disk blocks have been modified. During incremental backup, only the data of these blocks needs to be backed up.

[0051] You can reset the configuration of a virtual machine by calling the VMware vShpere API method ReconfigVM_Task and setting the parameters changeTrackingEnabled and changeTrackingEnabledSpecified to true.

[0052] 2. Generate a snapshot on the source virtual machine; after the snapshot is generated, all modifications will be recorded in the new snapshot disk file, which will not affect the master disk. At this time, backing up the master disk can ensure data uniqueness. Calling the CreateSnapshot_Task method of the VMware vShpere API can create a snapshot of the specified virtual machine.

[0053] 3. Save the complete configuration information of the source virtual machine; use the RetrievePropertiesEx method of VMware vSphere API to query all the configuration information of the source virtual machine and save it separately in the backup directory in the form of a file;

[0054] The purpose is to obtain the changeId information of each disk in the configuration during the next incremental backup. This changeID can be used to query the corresponding block modification record in step 1.

[0055] 4. The backup address is the local computer where the backup software is located; directly use the VDDK software API function VixDiskLib_Create to create a vmdk file in the backup directory, and then use the VixDiskLib_Open function to open the disk file, use the VixDiskLib_Read function to read the source disk file data, and use the VixDiskLib_Write function to write the data to the vmdk file in the backup directory.

[0056] 5. Determine whether the backup address is a remote share or a remote NFS share. If the backup is to a remote NFS share, ignore steps (1), (2), and (3).

[0057] (1) Create a temporary directory on a local disk of the backup software.

[0058] (2) Map the parent directory of the complete backup directory to the temporary directory in step (1) through a soft link (the subdirectory can be given a unique name).

[0059] Specifically: Under Windows, create a soft link using the following command: MKLink / D "soft link directory address" "real directory address".

[0060] (3) Start the NFS service software and convert the directory created in step (1) into an NFS service. The specific implementation is to pass the directory address created in step (1) as a startup parameter to the NFS software, and the NFS software will monitor this directory internally.

[0061] (4) Register the NFS service as a datastore on the VMware ESXi host that needs to be backed up. There are two ways to mount the NFS service on ESXi:

[0062] The first method is to use VMware vSphere API.

[0063] This API has a CreateNasDatastore method, which can be created by specifying the corresponding parameters; the parameters include: NFS server IP, directory created in step I, datastore name, access mode (read or readWrite). If it is NFS V41, you also need to specify the connection username and password.

[0064] The second method: using SSH commands;

[0065] Enable the ESXi SSH service and use the background command in the following format:

[0066] vim-cmd hostsvc / datastore / nas_create [datastoreName] [NFS version number] [NFS monitoring folder] [Is it read-only] [NFS server ip].

[0067] (5) Use the CreateVirtualDisk_Task function of the VMware vSphere API to create an empty disk file under the NFS path in step III. The size of the generated file is 0 by default and will increase dynamically based on the data written.

[0068] (6) Create a snapshot on the source virtual machine, then use the VixDiskLib_Open function to open the disk file in the datastore file path format, use the VixDiskLib_Read function to read the source disk file data, and use the VixDiskLib_Write function to write the data to the vmdk file in the backup directory.

[0069] (7) Download the .vmx configuration file of the backup virtual machine to the backup directory.

[0070] Embodiment 3

[0071] This embodiment provides an incremental backup method.

[0072] like Figure 2 As shown, implementing incremental backup includes the following steps:

[0073] The public SDK library provided by VMware does not have a method to directly generate a vmfs format incremental file. You need to use NFS to achieve this. The operation steps are the same as backing up to a remote share, as follows:

[0074] 1. Start the NFS service. If the backup set itself is stored on the NFS server, ignore this step.

[0075] The NFS service software and recovery software are deployed on the same computer.

[0076] When creating an NFS service, you need to specify a folder. During instant recovery, all data that ESXi needs to access remotely is in this folder. If the backup set is stored on another disk on the local machine or on a remote share, you need to create a soft link in the folder mapped by the NFS service. One instant recovery task corresponds to one soft link, which points to the actual storage location of the backup set.

[0077] In Windows, create a soft link using the following command: MKLink / D "soft link directory address" "real directory address".

[0078] After starting the NFS service, you need to record the corresponding folder (the folder monitored by NFS) path or alias.

[0079] 2. Mount the NFS share to ESXi. Only when the NFS service is mounted as a datastore on ESXi can ESXi correctly identify and read the backup files.

[0080] There are two ways to mount the NFS service on ESXi:

[0081] The first method uses the VMware vSphere API:

[0082] This API contains a CreateNasDatastore method, which can be used to create a datastore by specifying the corresponding parameters.

[0083] The second method is to enable the ESXi SSH service and use background commands. The command format is:

[0084] vim-cmd hostsvc / datastore / nas_create [datastoreName] [NFS version number] [NFS monitoring folder] [Is it read-only] [NFS server ip].

[0085] 3. Register the backup file to ESXi as a virtual machine:

[0086] (1) In the folder of the last backup point of the selected backup set, clone the .vmx file of the virtual machine and rename it with _ins appended to the original name. For example, if the original name is test.vmx, the cloned file will be test_ins.vmx.

[0087] (2) Register the virtual machine to ESXi.

[0088] There are two ways. The first one is to call the RegisterVM_Task method in VMware vSpere API, passing the configuration file name in the first step and the name of the virtual machine after instant recovery.

[0089] The second method: Open ESXi SSH and call the command vim-cmd solo / registervm test_ins.vmx

[0090] 4. Create a snapshot;

[0091] After successfully registering the virtual machine, create a snapshot immediately and record the specific snapshot disk file name. Specific method:

[0092] (1) Use the RetrievePropertiesEx method of the VMware vSphere API to query the virtual machine's hardware configuration information (config.hardware.device), find the virtual disk device configuration list, and then obtain the disk file name from each virtual machine disk device.

[0093] (2) After taking a snapshot, download the .vmx configuration file of the source virtual machine and obtain all parameter values ​​after .firleName=node from the configuration file to obtain the disk file name.

[0094] 5. Create an incremental backup directory and move the latest snapshot file to the incremental backup directory; because the snapshot disk file path cannot be specified when creating a snapshot of a virtual machine, the default path is the path of the virtual machine's current disk file before the snapshot is created. That is, in this solution, a new snapshot disk file will be generated by default in the full backup path or the previous incremental backup path.

[0095] Therefore, after creating a snapshot, you need to copy the newly generated snapshot disk file (.Avhdx or .Avhd) to the newly created incremental backup directory.

[0096] You can find out which files to copy based on the snapshot disk file name recorded in step 4.

[0097] 6. Unregister the virtual machine. The purpose of mounting the virtual machine using NFS is to generate a vmdk file in vmfs format that can be recognized by ESXi. After the snapshot is successfully created, the incremental vmdk file in the backup directory has been generated and the virtual machine is no longer needed. After obtaining the newly created snapshot disk file in step 4, unregister the virtual machine registered in step 5 from ESXi.

[0098] 7. Write incremental data: Based on the virtual machine disk configuration information obtained in step 4, loop through the uuid of each disk and read the configuration file information from the last backup directory. Obtain the changed corresponding to each uuid.

[0099] By calling the QueryChangedDiskAreas method of the VMware vSphere API, you can query the changed block data records, then use the VixDiskLib_Open function to open the incremental backup disk file, use the VixDiskLib_Read function to read the source incremental disk file data, and use the VixDiskLib_Write function to write the data to the vmdk file in the backup directory.

[0100] Explanation of professional terms:

[0101] ESXi: is a free to install and secure open source operating system software developed by VMware, which is designed to run a cluster of virtual machines. It is a component of VMware vSphere, a server virtualization platform for managing and running virtual machines.

[0102] NFS: stands for Network File System, which is a protocol for sharing files and directories between computer systems. NFS is widely used in UNIX and Linux operating systems. It allows remote computers to access and operate remote files as if they were local files, thus facilitating file sharing and collaboration between multiple computers.

[0103] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0104] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for backing up a VMware virtual machine, characterized in that: The following steps are involved: Step S1, start source virtual machine block tracking; Used to record the modified data of modified disk blocks; Step S2, creating a snapshot of the source virtual machine; After the snapshot is generated, the snapshot disk file is used to record all modifications; Step S3, save the complete configuration information of the source virtual machine; the saved configuration is used for the next backup, and the changeID information of each disk in the configuration is obtained, and the corresponding block modification data in step S1 can be queried using the changeID; Step S4, determine whether to back up to the local; If yes, jump to step S10; if no, go to step S5; Step S5, determining whether to back up to NFS, if yes, directly starting NFS, if not, creating a temporary NFS directory; Step S6, creating an MKlink from the complete backup directory to the NFS temporary directory; Step S7, starting the NFS service; By passing the NFS temporary directory address created in step S5 as a startup parameter to the NFS software, the NFS software will monitor this directory internally; Step S8, mount NFS to EsXi; register the NFS service as datastore on the ESXi host to be backed up; Step S9, creating a backup disk in the datastore; Step S10, calling the SDK to read and write disk data, downloading the configuration file of the backup virtual machine to the backup directory to complete the backup.

2. A VMware virtual machine backup method according to claim 1, characterized in that: In step S3, the complete configuration information of the source virtual machine is saved by using the RetrievePropertiesEx method of the VMware vSphere API to query all the configuration information of the source virtual machine and save it separately in the backup directory in the form of a file.

3. The method for backing up a VMware virtual machine according to claim 1, characterized in that: In step S6, creating a MKlink from the backup directory to the NFS temporary directory is specifically: mapping the parent directory of the complete backup directory to the NFS temporary directory created in step S5 by means of a soft link.

4. A method for backing up a VMware virtual machine according to claim 3, characterized in that: In Windows, create a soft link using the following command: MKLink / D "soft link directory address" "real directory address".

5. The method for backing up a VMware virtual machine according to claim 1, characterized in that: Mount NFS to EsXi using VMware vSphere API or using SSH commands.

6. A VMware virtual machine backup method according to claim 5, characterized in that: To use VMware vSphere API, use the CreateNasDatastore method in VMware vSphere API and specify the corresponding parameters to complete the mounting.

7. A VMware virtual machine backup method according to claim 6, characterized in that: Parameters include: NFS server IP, NFS temporary directory created in step S5, datastore name, and access mode.

8. The method for backing up a VMware virtual machine according to claim 7, characterized in that: To mount using SSH commands, open the ESXi SSH service and use background commands in the following format: vim-cmd hostsvc / datastore / nas_create [datastoreName] [NFS version number] [NFS monitoring folder] [Is it read-only] [NFS server ip].

9. The method for backing up a VMware virtual machine according to claim 1, characterized in that: In step S9, the backup disk is created in the datastore as follows: Use the CreateVirtualDisk_Task function of the VMware vSphere API to create an empty disk file in the NFS temporary directory.

10. The method for backing up a VMware virtual machine according to claim 1, characterized in that: In step S10, calling SDK to read and write disk data is specifically as follows: creating a snapshot on the source virtual machine, then using VixDiskLib_Open function to open the disk file in the file path format of datastore, using VixDiskLib_Read function to read the source disk file data, and using VixDiskLib_Write function to write the data to the vmdk file in the backup directory.