Backing Up, Restoring and Migrating VM(virtual machine)

This post will talk about how to backup, restore and migrate a virtual machine.

Duplicating a virtual machine

Duplicating or cloning means creating an identical copy of a VM. Most hypervisors support these configurations. By duplicating a VM, we will have a copy of all its specifications, including the machine’s name and specific addresses for connecting to the network.

Duplicating a VM and placing it on the network is not always a good practice because creating duplicate versions can cause similar IP addresses and thus cause problems. We mostly use duplicating to create backups.

Most hypervisors can clone a machine while it is powered off. If the hypervisor accepts a clone operation while the virtual machine is powered on, it suggests you shut down the virtual machine first, as this process can cause the virtual machine to crash. We have explained cloning in practice in the article Working with VMware Workstation, which you can refer to for more information.

Back up and restore the virtual machine.

Here are three methods for backing up virtual machines:

Method 1 backup, restore virtual machine

One of the most common ways is to install backup software from hosted virtual machines. If the Windows operating system is used on the virtual machine, we can use the Backup and Restore option to backup the virtual machine, and this option is located in the Control Panel section.

For Linux operating system, you can use various open-source tools depending on your needs; for example, you can refer to Bacula and rsync.

Method 2 backup, restore the virtual machine.

Another strategy or method to copy all files is to define a VM. That’s why we need to exit the virtual machine and copy all the files that define our VM to another place. Some of these files can be very large.

For example, we have created some virtual machines with VirtualBox software, as shown below. AC2, Kali2016.1, and Test and Windows 2012, respectively.

Right-click on the virtual machine to find the files that need to be copied or make a backup copy. Go to the Storage section and then hover your mouse over the virtual hard disk to see the full path where the virtualized desktop files are located.

We need to save all these files somewhere else.

Method 3 backup, restore the virtual machine.

The third option for backing up and restoring virtual machines is to use the software provided by other companies.

Converting a physical server to a virtual server

In this section, we will learn how to convert a physical server into a virtual machine. This issue is often referred to as P2V in technical literature.

VMware has released a product known as vCenter Converter that can convert physical machines into virtual machines in a special way. You can download this software from https://www.vmware.com/products/converter.html.

Microsoft also has a product called Disk2vhd that can convert a physical hard drive into a virtual hard drive (VHD). You can download this software from the link – https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx.

Here we need to install the software on the physical server and click on the Create option, as shown in the screenshot below. A VHDX file is created that can be imported into a hypervisor.

Both of these products can convert machines while the server is running and idle. Most hypervisor vendors have specific P2V tools, which are free. From suppliers’ point of view, converting physical machines to virtual machines can optimize the performance of their supplied hypervisors.

Converting a virtual server to a physical server

There are ways to convert a virtual server into a physical server, called V2P if this method is used less than the P2V method. However, sometimes there is a need to make changes or developments depending on the work environment. For example, when we need the product to be tested on a virtual server instead of a physical server, or a virtual machine sample is prepared and used to test if it works correctly, it is logical to use the P2V method.

Hypervisor vendors do not typically provide these tools. However, you can request such tools if you need them and if the suppliers do not provide them.

If you have any questions or suggestions about this post, you can comment at the bottom. And we will answer all of them as soon as possible.