Backing up VirtualBox virtual machines. Import and Export of a virtual machine in VirtualBox Windows script for virtualbox backup

Backup technologies have proven themselves so well that they have begun to be used in a variety of areas, even in virtual machines. Let's take, for example, the most popular program for virtualizing operating systems.

This amazing tool allows you to test even potentially dangerous software without the risk of damaging the actual operating system. If something happens, you can simply delete the virtual machine.

However, the VirtualBox developers considered it necessary to implement a backup function in the virtual machine - creating snapshots or snapshots.

It's a pity, but very few VirtualBox users resort to its help, preferring the tedious reinstallation procedure to several mouse clicks. Think about how much valuable time you are wasting by neglecting the snapshot feature.

And what should you do if a lot of useful software is installed on the virtual machine? Why remove and reinstall a virtual OS if you can create a snapshot of it, and then, if something bad happens, just roll back it? But creating a snapshot in VirtualBox is very simple.

With the virtual system running, select “ ” from the “Machine” menu. A small window will open in which you will be asked to give a name to the snapshot (by default, snapshot No.) and a brief description. That's all.

The basis for creating snapshots is Copy-On-Write technology, which is a copy-on-write mechanism. To put it in more understandable terms, when a snapshot is created, only those areas that are accessed by the operating system for recording purposes are backed up. This is the main difference from a full backup, for example, cloning a virtual machine, which takes much more time and.

Where are VirtualBox snapshots stored? Snapshots of the virtual OS are stored on the system disk in the VirtualBox VMs folder. They represent themselves as two files with the extensions vdi and sav.

How to work with snapshots? Very simple. You can access snapshots from the VirtualBox manager window by clicking on the “Snapshots” button. Snapshots are arranged in a tree structure, which is very convenient. By right-clicking on the selected image, you can view a list of available operations.

You can delete or clone a snapshot, perform a rollback, and view detailed information. Recovery is performed when the virtual machine is turned off and occurs very quickly, much faster than the virtual operating system starts.

Bottom line

That's all about creating backups in VirtualBox.

Agree, this is much faster and more convenient than creating full-sized clones of a virtual system. Of course, such pictures, like any other one, take up some space on your hard drive, but it would still be better to sacrifice two or three gigabytes of disk space than the precious time and effort spent on reinstalling the operating system

Using VM Groups

VM groups allow the user to create special groups of virtual machines for collective management.

Create a group using the GUI

1) Drag one virtual machine on top of another virtual machine.

2) Select multiple virtual machines and select " Group» in the right-click menu as shown below:

You can create nested groups.

Group operations allow you to perform common actions for virtual machines for all members of the group at once.

Pictures

With snapshots, you can save a specific state of a virtual machine for later use. At any subsequent time you can return to this state, even though you may have changed the VM significantly since then. So a snapshot of a virtual machine is similar to a machine in a "saved" state as described above, but there can be many of them, and these saved states are stored permanently.

You can see snapshots of a virtual machine by first selecting the machine in VirtualBox Manager and then clicking the " Pictures" in the upper right corner. Until you take a picture of the car, the list of pictures will be empty, except for the item " Current state", which represents the point " Now"in the life of a virtual machine.

Creating, restoring and deleting snapshots

There are three operations associated with snapshots:

  1. You can to take a photo. This makes a copy of the current state of the machine, which you can later return to at any time.
  • If your virtual machine is currently running, select " Take a snapshot of the state..." in the drop-down menu " Car» VM windows.
  • If your virtual machine is currently in the " saved" or " off" (as shown next to the virtual machine in the main VirtualBox window), click the " Pictures" in the upper right corner of the main window, and then
    • or on the small camera icon (for “ To take a photo"), or
    • right click on the element " Current state" in the list and select " To take a photo».

In any case, a window will appear asking for the name of the image. This name is for reference purposes only to help you remember the snapshot status. For example, a useful name would be " Fresh installation from scratch, without guest additions th" or " Service pack only 3". You can also add longer text in the " Description", if you want to.

Your new snapshot will then appear in the list of snapshots. Below the new photo you will see an item called " Current state", meaning that the current state of your virtual machine is a variant based on the snapshot you used previously. If you later take another photo, you'll see that they will appear sequentially, with each subsequent photo derived from the earlier one:

VirtualBox doesn't place any restrictions on the number of pictures you can take. The only practical limitation is the disk space on your host: each snapshot saves the state of the virtual machine and thus takes up some disk space.

  1. You can restore snapshot by right-clicking on any photo you took in the list of photos. Restoring a snapshot is like going back to the moment it was taken: the current state of the car is lost, and the car is returned to the exact state the car was in when the snapshot was taken.

Note Note: Restoring a snapshot will affect the virtual hard disks attached to your virtual machine. This also means that all files created since the snapshot was taken and all other changes to files will be lost. To prevent data loss when using the Snapshot feature, you can add a second hard drive in " write-through» using the VBoxManage interface and use it to store your data. Because writable hard drives are not included in snapshots, they remain unchanged when the machine is returned.

To avoid losing the current state when you restore a snapshot, you can create a new snapshot before restoring.

By restoring an earlier snapshot and taking more snapshots, you can create a sort of alternate reality and switch between these different histories of the virtual machine. This may result in a tree of virtual machine snapshots as shown in the screenshot above.

  1. You can also delete the snapshot, which will not affect the state of the virtual machine, but only release the disk files that VirtualBox used to store the snapshot data, thereby freeing up disk space. To delete a snapshot, right-click it in the snapshot tree and select " Delete" Since VirtualBox 3.2, snapshots can be deleted even while the machine is running.

Note Note: While creating and restoring snapshots are fairly fast operations, deleting a snapshot can take a significant amount of time because it may require copying a large amount of data between multiple disk image files. Temporary disk files may also require a large amount of disk space while the operation is running.

There are some situations that cannot be processed while the virtual machine is running, and you will receive a corresponding message that you should delete this snapshot while the virtual machine is turned off.

Think of a snapshot as time that you have saved. More formally, a photograph consists of three things:

  1. It contains a complete copy of the virtual machine settings, including hardware configuration, so that when the snapshot is restored, the VM settings are also restored. (For example, if you change the hard drive configuration or system settings of the virtual machine, that change is discarded when the snapshot is restored.)
  2. A copy of the settings is saved in the device configuration, an XML text file and therefore takes up very little space.
  3. The full state of all virtual disks attached to the machine is saved. Returning to a snapshot means that all changes made to the computer's disks - file by file, bit by bit - will also be undone. Files created since creation will disappear, files that have been deleted will be restored, changes to files will be undone.

(Strictly speaking, this is only true for virtual hard disks in "normal" mode. As mentioned above, you can configure the disks to behave differently with snapshots. Even more formally and technically correct, restoring a snapshot does not restore the virtual disk itself Instead, when a snapshot is taken, VirtualBox creates diff images that contain only the changes since the snapshot was taken, and when the snapshot is restored, VirtualBox discards that diff image, thus reverting to the previous state. This is faster and uses less disk space.

Creating a differential image as such initially does not take up much space on the host's disk, since the differential image will initially be empty (and later grow dynamically with each disk write operation). However, the longer you use the machine after taking a picture, the more the size of the different image will increase.

Finally, if you took a snapshot while the machine was running, the device's memory state is also saved in the snapshot (just as memory can be saved when closing a VM window). When you restore such a snapshot, execution resumes at the exact moment the snapshot was taken.

The memory state file can be as large as the virtual machine's memory and therefore take up quite a lot of disk space.

Removing virtual machines

To delete a virtual machine that you no longer need, right-click it in the VM Manager list, select " Delete».

A confirmation window appears allowing you to choose whether to remove the machine from the list of machines only, or whether to also delete the files associated with it.

Menu item " Delete

Cloning virtual machines

To experiment with a virtual machine's configuration, test different levels of a guest OS, or simply create a backup of a virtual machine, VirtualBox can create a full or linked copy of an existing virtual machine.

The wizard will guide you through the cloning process:

This wizard can be called from the VM Manager list context menu (select " Clone") for the selected virtual machine. First, choose a new name for the clone. You can select the option to generate MAC addresses of all network cards, then each network card in the clone will receive a new MAC address. This is useful when both the source VM and the cloned virtual machine need to run on the same network. If you leave this unchanged, all NICs will have the same MAC address as the one in the source VM. Depending on how you invoke the wizard, you have different options for the cloning operation. First you need to decide whether the clone should be linked to the original VM or a completely independent clone:

Full cloning: In this mode, all disk image dependencies are copied to a new VM folder. The clone can run completely without the original virtual machine.

Linked cloning: This mode creates new distinctive disk images where the parent disk images are images of the source disk. If you selected the current state of the source VM as the cloning point, a new snapshot will be created implicitly.

After selecting the cloning mode, you need to decide what exactly you want to clone. You can always create a clone of just the current state or everything. When you select all, the current state and in addition all snapshots are cloned. If you started with a snapshot with additional children, you can also clone the current state and all children. This creates a clone starting from this snapshot and including all child snapshots.

The cloning operation itself can be lengthy depending on the size and number of disk images attached. Also keep in mind that each snapshot has different disk images that need to be cloned as well.

Menu item " Clone» switches off while the machine is running.

Import and export of virtual machines

VirtualBox can import and export virtual machines in the standard Open Virtualization Format (OVF).

OVF is a cross-platform standard supported by many virtualization products that allows you to create ready-made virtual machines that can then be imported into a virtualizer such as VirtualBox. Importing and exporting into VirtualBox in OVF format is very simple and is done from the Manager window, as well as the command line interface. This allows you to package so-called virtual devices: disk images along with configuration settings that can be easily deployed. This way you can offer complete, ready-to-use software packages (operating systems with applications) that require no configuration or installation other than importing into VirtualBox.

Note: The OVF standard is complex and its support in VirtualBox is an ongoing process. In particular, VirtualBox is not guaranteed to support all devices created by other virtualization software.

Devices in OVF format can be displayed in two options:

  1. They may be supplied in multiple files as one or more disk images, usually in the widely used VMDK format and an XML text file with the extension .ovf. To be able to import them, the files must be in the same directory.
  2. Alternatively, the above files may be packaged together into a single archive file, typically with the extension .ova. (Such archive files use a variant of the TAR archive format and therefore can be unpacked outside of VirtualBox with any utility that can unpack standard TAR files.)

To import device into one of the above formats, simply double-click the OVF/OVA file. Or select " File» → « Importing configurations" in the Manager window. In the file dialog box that appears, navigate to the file with the extension .ovf or .ova.

If VirtualBox can process this file, a dialog box similar to the following will appear:

It represents the virtual machines described in the OVF file and allows you to change the settings of the virtual machine by double-clicking the description elements. Once you click " Import", VirtualBox will copy the disk images and create local virtual machines with the settings described in the dialog box. They will then appear in the Manager's list of virtual machines.

Please note: Because disk images tend to be large, and the VMDK images that come with virtual appliances are typically sent in a special compressed format that is not suitable for direct use by virtual machines, the images will first need to be uncompressed and copied, which may take several minutes .

And vice versa, for export virtual machines that you already have in VirtualBox, select " File» → « Export configurations" Another dialog box will appear that allows you to combine multiple virtual machines into an OVF device. Then select the location where the target files should be saved and the conversion process will begin. It can take some time.

Note: OVF cannot describe the snapshots that were taken for the virtual machine. As a result, when exporting a virtual machine with snapshots, only the current state of the machine will be exported, and the disk images in the export will have a “flattened” state identical to the current state of the virtual machine.

Global Settings

The global settings dialog can be found in the menu " File", selecting the item " Settings….» It offers a set of settings that apply to all virtual machines of the current user or, in the case of extensions, to the entire system:

  • Are common. Allows the user to specify the default folder/directory for VM files and the VRDP authentication library.
  • Enter. Allows the user to specify a Host key. It is used to switch the cursor out of focus of the virtual machine or host operating system windows, and is also used to trigger certain virtual machine actions.
  • Updates. Allows the user to specify various automatic update options.
  • Language. Allows the user to specify the language of the graphical user interface.
  • Display. Allows the user to specify the screen resolution, as well as its width and height.
  • certificate . For a special discount on any faculties and courses!

Reinstalling the operating system or changing a computer device does not mean the end of working with installed guest OSes in the program. True, an exception may be the case when the virtual machine hard drive files are located on the computer’s system drive, and the system itself cannot be restored after a critical failure. To continue working with existing guest OSes while maintaining their state, but on a reinstalled Windows or on another computer, the VirtualBox program has a tool for exporting the configuration of existing virtual machines for importing it later. Another option to continue working with existing guest OSes is to add new virtual machines based on existing files on their hard drives. We will consider all these processes below.

1. Universal virtual machine export file format

The configuration of an existing VirtualBox virtual machine is exported to the file " .ova" An “.ova” (Open Virtual Appliance) file is a universal virtual machine data storage file that can be used in various programs for virtualizing operating systems. This , . The virtual machine exported to this file can then be imported by either VirtualBox, VMware Workstation or Microsoft Hyper-V within the guest systems supported by these programs.

Let's take a closer look at the process of exporting and importing the configuration of the VirtualBox virtual machine in the main Windows system.

2. Export a virtual machine

In the VirtualBox window, select a specific virtual machine to export, click the menu “ File" and select " Export configurations».

In the next window, click " Next».

Exporting a configuration is only possible when the virtual machine is powered off, and if it is paused, VirtualBox will prompt you to reset the saved state to continue the process.

Next, the export options window will appear. We leave the preset format, but change the export file folder “.ova”, which is located on the system drive by default, to a folder, for example, as in our case, specially created on the non-system drive D.

In the next window, click " Export».

We are waiting for the export process to complete.

The exported virtual machine in the “.ova” file will be located in the specified folder, from where it can be moved to another computer, removable media, or to a cloud service. Or you can leave it, as in our case, in place - on a non-system drive, where this file will be stored during Windows reinstallation.

3. Import a virtual machine

After installing VirtualBox on a new Windows or on another computer, open the program and in the menu “ File» select « Importing configurations».

In the next window, specify the path to the “.ova” file with the exported virtual machine. Click " Next».

At the very end of the window, the path will be indicated where the “.vdi” hard disk file will be placed after import. By default, this is the system drive, and in order not to clutter it and prevent the loss of the “.vdi” file in the event of a system failure, you can change the path by specifying the storage folder on a non-system drive. Click " Import».

We are waiting for the import process to complete.

After which we will see the imported virtual machine in the list of VirtualBox machines. All that remains now is to start the car.

The guest OS will start in exactly the state it was in at the time the virtual machine was exported.

4. Adding a new machine from an existing VirtualBox hard disk file

An alternative to exporting and importing a virtual machine is to add a new machine from an existing VirtualBox hard drive file. .vdi" This method is in no way inferior to the procedure for exporting and importing a virtual machine. Moreover, if the “.vdi” file is located on a non-system drive, when you reinstall Windows on a physical computer, you don’t even have to waste time exporting the configuration. We can simply transfer the “.vdi” file stored on the system disk to a non-system disk. By and large, the process of exporting and importing a virtual machine benefits only by saving the space taken up by the “.ova” file. For example, in our case, we exported a virtual machine with the Windows XP guest OS installed, and the weight of the “.ova” file at the output was 4,11 GB While the size of the hard disk “.vdi” file of the same system is 10 GB.

This space-saving benefit may be relevant if you transfer a virtual machine to another computer using cloud storage or removable media with a limited size. In our case, when we are talking about reinstalling Windows, the method of adding a new machine from an existing VirtualBox hard disk file is quite suitable.

Launch VirtualBox and click " Create».

We set the RAM indicator. Click " Next».

In the hard drive selection window, select the option “ Use an existing hard drive", using the browse button, specify the path to store the ".vdi" file. Click " Create».

The virtual machine will appear in the VirtualBox list, we can launch it.

The guest OS will start exactly in the state in which it was saved the last time you worked with it.

Adding a new virtual machine from an existing “.vdi” file is also a way to move the guest OS hard disk file to a non-system drive of the computer if it was originally created on the system drive, and over time the space it occupied began to reduce system performance. To do this, you need to remove the virtual machine from the list in the main VirtualBox window. On the selected machine, call up the context menu and select “ Delete».

Then in the window that appears, click “ Remove from list».

After this, you can search for the hard disk “.vdi” file on the system drive (usually the default path C:\Users\Username\VirtualBox VMs), move it to a non-system disk and add the virtual machine again.

Did this article help you?

Copyright © Acronis International GmbH, 2002-2013

To be able to update a virtual machine, the program stores several

intermediate snapshots with names Backup copy… And Replica…; their

needs to be stored. Unneeded snapshots are deleted automatically.

Last snapshot Replica… corresponds to the result of the latter

transformations. You can go to this snapshot to return the machine to this

condition, for example, if after working with the machine you need to cancel the changes made.

Other snapshots are for internal use by the program.

6.2.3 Restoring to a “New virtual machine”

Instead of converting the .tib file to a virtual disk file, which requires additional

steps to start working with a virtual disk, Acronis Backup & Recovery 11.5 performs

conversion by restoring a disk backup to a fully configured and

a running new virtual machine. While setting up a restore operation

you can adapt the configuration of the virtual machine to the requirements of the situation.

By using Acronis Backup & Recovery 11.5 Agent for Windows or agent for Linux Can

create a new virtual machine in a local or network folder. You can start the car

using appropriate virtualization software or prepare

machine files for further use. The following table contains information about

available virtual machine formats and steps you can take to

adding a machine to the virtualization server.

VM format

Next steps and tool to use Target platform

virtualization

VMware Workstation

Export using VMware Workstation or
convert to OVF by selecting VMware OVF Tool >

Deploy OVF template (VMware OVF Tool >

Deploy OVF template to vSphere Client

Microsoft Virtual PC*

Add VHD file to Hyper-V machine

Citrix XenServer OVA

Import using Citrix XenCenter

Virtual machines on

kernel-based (sector-by-sector

Move the virtual machine files to

machine running Linux OS and start the virtual machine

using Virtual Machine Manager

Red Hat Enterprise

Virtualization (RHEV)

(sector format)

Import using RHEV Manager

*Microsoft Virtual PC does not support disks larger than 127 GB. With Acronis you can create

a Virtual PC machine with larger disks to attach the disks to the virtual machine

Microsoft Hyper-V.

By using Acronis Backup & Recovery 11.5 Agent for Hyper-V or agent for ESX(i) Can

create a new virtual machine directly on the corresponding virtualization server.

Necessary steps

How to restore to a new virtual machine

1. Connect the console to the management server, to the machine on which the agent is installed, or to

machine booting from bootable media.

2. Press the button Restore to open the page Data recovery(p.

Did you like the article? Share it
Top