Embodiments of the present disclosure generally relate to the field of storage and backup, and more particularly to a method, device, and computer program product for backing up a virtual machine.
Data backup refers to backing up data to other storage devices, and data may be recovered through backup to avoid unnecessary loss of data when a data failure or disaster occurs. The backup types of data backup may be classified into full backup, incremental backup, differential backup, and selective backup. Data backup may be classified into hot backup and cold backup depending on whether the system is in a normal operation state.
A virtual machine is a complete computer system which is simulated through software, has complete hardware software functions and runs in a fully isolated environment. Through virtualization software, a user may simulate one or more virtual machines on a single physical computer. The computer hardware resource become a detachable resource through virtualization technology, and the detached resources form a virtual machine, which possesses service capabilities provided by the original hardware. For example, it is possible to install one operating system on another operating system, which enables the computer to run both operating systems simultaneously. The virtual machine may be used for software development and test, and be widely used in the server industry.
Embodiments of the present disclosure provide a method, device, and computer program product for backing up a virtual machine.
In one aspect of the disclosure, there is provided a method for backing up a virtual machine. The method comprises obtaining a first file path in a first operating system installed on a virtual machine, wherein the virtual machine runs on a second operating system. The method further comprises determining a second file path in the second operating system corresponding to the first file path based on the first file path, and backing up a file in the virtual machine based on the second file path.
According to another aspect of the present disclosure, there is provided a device for backing up a virtual machine. The device comprises a processing unit and a memory coupled to the processing unit and storing instructions thereon. The instructions, when executed by the processing unit, perform the acts comprising obtaining a first file path in a first operating system installed on a virtual machine, wherein the virtual machine runs on a second operating system. The acts further comprises determining a second file path in the second operating system corresponding to the first file path based on the first file path and backing up a file in the virtual machine based on the second file path.
According to a further aspect of the present disclosure, there is provided a computer program product that is tangibly stored on a non-transient computer readable medium and includes machine-executable instructions. The machine-executable instructions, when executed, cause a computer to execute the method or process according to embodiments of the present disclosure.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The above and other features, advantages and aspects of embodiments of the present disclosure will be made more apparent by describing the present disclosure in more detail with reference to figures. In the figures, the same or like reference signs represent the same or like elements.
Preferred embodiments of the present disclosure will be described below in more detail with reference to figures. Although figures show preferred embodiments of the present disclosure, it should be appreciated that the present disclosure may be implemented in various forms and should not be limited by embodiments stated herein. On the contrary, these embodiments are provided to make the present disclosure more apparent and complete, and to convey the scope of the present disclosure entirely to those skilled in the art.
As used herein, the term “includes” and its variants are to be read as open terms that mean “includes, but is not limited to.” Unless otherwise specified, the term “or” represents “and/or”. The term “based on” is to be read as “based at least in part on.” The term “an implementation” is to be read as “at least one implementation.” The term “another implementation” is to be read as “at least one other implementation.” Terms “first” and “second” may refer to different or identical objects, unless otherwise it is explicitly specified that they refer to different objects.
Generally, a virtual machine may be installed on a real operating system, and then a virtual operating system may execute in the virtual machine. Because the virtual operating system is a closed, complete system, the application or software executing in the real operating system cannot obtain a real path of the path specified by the user in the virtual operating system. Therefore, it is usually only possible to use a full backup mode for the virtual machine, and typically not possible to implement partial backup of the virtual machine. If the user needs to exclude the backup or only backup a specified path in the virtual machine, the traditional solution cannot be implemented. On the contrary, the traditional methods can only perform the full backup, which typically wastes storage space and network bandwidth.
To this end, embodiments of the present disclosure propose a new scheme for backing up a virtual machine. Embodiments of the present disclosure may exclude and/or reserve a user-specified folder or file during virtual machine backup by mapping a file path in the virtual machine to a file path in the real operating system, thereby saving storage space and network bandwidth. Thus, in accordance with embodiments of the present disclosure, the scenarios of data backup are greatly expanded, and the user may specify to exclude backing up and/or only backup certain paths and/or files in the virtual machine.
The basic principles and several example implementations of the present disclosure are described below with reference to
Referring to
Because the backup application 121 runs on the operating system 120, it does not understand the meaning of the drive letter (e.g., “D:”) in the virtual operating system 111. Thus, embodiments of the present disclosure may map drive letters in the virtual operating system to the real operating system by mapping file paths of two operating systems. In general, the backup application 121 may use a Master File Table (MFT) of the New Technology File System (NTFS) to locate a logical cluster number (LCN), a virtual cluster number (VCN), and length of the file. For files that need to be excluded from backup, the backup application 121 will bypass the blocks of these files when backing up.
At 202, a first file path in the first operating system installed on the virtual machine is obtained, and the virtual machine runs on the second operating system. For example, the backup application 121 may obtain a user-specified path in the operating system 111 installed on the virtual machine 110, for example, a user may enter a path “d:\logs” in the backup application 121, which may be used to indicate that the user wants to exclude backup of files in this file path, or the user only needs to backup the files in this file path.
At 204, a second file path in the second operating system corresponding to the first file path is determined based on the first file path. For example, it is possible to map the file path “d:\logs” in the virtual operating system 111 to a corresponding partition or path in the real operating system 120, and after determining the partition corresponding to the drive letter “d:”, the real path corresponding to the file path “d:\logs” can be determined. An example implementation about how to determine a partition corresponding to a drive letter is described below with reference to
At 206, one or more files in the virtual machine is backed up based on the second file path. After obtaining the corresponding second file path, the backup application 121 may perform a corresponding virtual machine backup action. For example, the backup application 121 may exclude from the backup the contents in the backup file path “d:\logs”. In some embodiments, the backup application 121 may determine one or more file paths that the user wants to backup and/or one or more file paths that the user does not want to backup, and then perform the corresponding virtual machine backup process.
Thus, embodiments of the present disclosure can exclude and/or reserve a user-specified folder or file during the backup of virtual machine by mapping the file path in the virtual machine to the file path in the real operating system, thereby saving the storage space and network bandwidth. By contrast, the traditional backup systems may at most only exclude some files in the root path, but cannot exclude backup of contents in the user-specified file path of virtual machine.
At 302, after a snapshot is created for the virtual machine 110, a virtual machine tool is used to install the virtual snapshot in the backup application 121, and then a loop device command is assigned to a virtual disk (VMDK) file in the virtual machine 110, such that the backup application 121 can operate the virtual disk file like operating a block device. The VMDK is a virtual hard format created by the virtual machine. The file exists in the virtual file system and is called VMFS (Virtual Machine File System). One VMDK file usually represents a physical hard drive of VMFS on the virtual machine. All user data and configuration information related to the virtual server are stored in the VMDK file.
At 304, a partition table format of the virtual disk is determined. If the partition table is in the Master Boot Record (MBR) format, a disk signature of the MBR disk is obtained at 306, which is usually located at offset 440 of a first sector. If the partition table is in the GUID Partition Table (GPT) format, a second sector of the GPT disk is obtained 308 to find GPT header information to obtain the partition summary information. Then, based on the partition summary information, the corresponding offset is jumped to the related partition to get the unique partition GUID at offset 16.
For example,
MBR is a boot code located at the forefront of a disk, it is responsible for discriminating the legality of the partition and positioning the partition boot information when the disk operating system reads from and writes to the disk, and it is generated by the disk operating system when the hard disk is initialized. GPT is a structural layout standard of a hard disk partition table, it is a part of an Extensible Firmware Interface (EFI) standard and is used to replace 32 bits in the BIOS system to store the Master Boot Record (MBR) Partition Table of the logic block address and size information.
Returning to
At 312, the folder in which the virtual operating system is located, and a registry file of the virtual operating system is obtained from the folder. For example, NTFS MFT is searched and a folder that includes the virtual operating system is searched. For example, for a Windows virtual operating system, it is possible to first attempt to search for “windows”, “winnt”, “Windows”, etc. If not found, it is possible to search for “bootstat.dat” at the root level, which is specific to one file of the Windows operating system. After the folder in which the Windows operating system is located, the registry file is obtained from the folder.
It should be appreciated that although the embodiment of the present disclosure is described with the Windows operating system as the virtual first operating system. However, the first operating system may also be another operating system. In addition, specific information specific to other operating systems may be used to locate the folder of this operating system in another operating system.
The registry is the core database of the Windows operating system, and it stores various parameters and directly controls the startup of Windows, the loading of hardware drivers, and the running of some Windows applications. Returning to
The obtained entries having the specified prefix may be stored or cached as a repository or dictionary 316, with multiple entries in the dictionary 316, each entry includes a drive letter and a corresponding identifier. In some embodiments, each entry has a key-value pair, the key in the key-value pair includes a specified prefix and a drive letter in the file path of the virtual operating system, such as “\DosDevices\D:”, and the value in the value key-value pair includes a partition identifier such as “65 91 e2 fd 00 . . . ”.
Next, at 318, matching between the disk signature or partition GUID and the entries in the dictionary 316 may be performed. For example, for an MBR disc, its disk signature+partition start offset is used to match with the partition identifier in the dictionary 316, and the actual partition corresponding to the MBR drive letter in the virtual machine may be determined. For another example, for a GPT disk, the prefix 444d494f3a49443a+ partition GUID may be used to match with the partition identifier in the dictionary 316, so that the actual partition corresponding to the GPT drive letter in the virtual machine may be determined. After determining the actual partition corresponding to the drive letter in the virtual machine, the actual file path corresponding to the virtual file path may be determined, thereby implementing the function of partial backup for the virtual machine.
Various components in the device 600 are connected to the I/O interface 605, including: an input 606 such as a keyboard, a mouse and the like; an output unit 607 including various kinds of displays and a loudspeaker, etc.; a storage unit 608 including a magnetic disk, an optical disk, and etc.; a communication unit 609 including a network card, a modem, and a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information/data with other devices through a computer network such as the Internet and/or various kinds of telecommunications networks.
Various processes and processing described above may be executed by the processing unit 601. For example, in some embodiments, the method may be implemented as a computer software program that is tangibly embodied on a machine readable medium, e.g., the storage unit 608. In some embodiments, a part or all of the computer programs may be loaded and/or mounted onto the device 600 via ROM 602 and/or communication unit 609. When the computer program is loaded to the RAM 603 and executed by the CPU 601, one or more steps of the method as described above may be executed.
In some embodiments, the method 200 described above may be implemented as a computer program product. The computer program product may include a computer readable storage medium which carries computer readable program instructions for executing aspects of the present disclosure.
The computer readable storage medium can be a tangible device that can reserve and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present disclosure may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language, and conventional procedural programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.
These computer readable program instructions may be provided to a processing unit of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The descriptions of the various embodiments of the present disclosure have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Number | Date | Country | Kind |
---|---|---|---|
201811247622.9 | Oct 2018 | CN | national |