Hyper-V: “The virtual disk … was copied while it was still in use”
This page is intended for administrators backing up Hyper-V virtual machines with the BeBackup agent installed on the host. It explains the warning that appears when a virtual disk is copied while its machine is running, why the resulting backup may be incomplete, and how to correctly back up a machine that is powered on. It applies to BeBackup agent 7 for Windows.
Symptom
The backup report contains the following warning:
Virtual disk "…" was copied while still in use: its internal log had not been closed. The backed-up content is what the hypervisor had written to the file, and it may be older than the live state of the guest machine. To back up a running machine, you must use the Hyper-V VSS writer, the only component able to quiesce the guest file system.
The backup completes, but with a warning. On restore, recent files from the virtual machine may be missing.
Cause
The virtual disk (.vhdx file) of a running machine is permanently open by Hyper-V. The guest operating system keeps some of its writes in memory. They have not yet been committed to the .vhdx file.
When the agent copies this file as an ordinary file, it obtains what Hyper-V has written to the host's disk. It does not obtain what the guest machine is holding in memory. The backed-up content is therefore consistent, but it may be out of date.
The VSS (Volume Shadow Copy Service) snapshot taken on the host does not resolve this issue. It freezes the host's file system. It cannot flush the guest machine's memory.
The agent detects this situation by reading the state of the virtual disk's internal log. A disk whose log has not been closed triggers the warning. The same applies to a disk that was shut down abruptly, for example after a power failure on the host, even if the machine is powered off at the time of the backup.
This warning only concerns virtual disks read file by file, through the profile's Virtual disk contents rules.
A
.vhdxfile in use that is simply copied as an ordinary file, because its folder is part of the selection, triggers no warning. The copy takes place without notice, with the same limitation: its content may be older than the live state of the machine. The absence of a warning is therefore no proof that the copy is consistent.
Checks
- Identify the virtual disk named in the warning. Find the virtual machine that uses it.
- Check whether that machine was powered on at the time of the backup.
- If it was powered off, check whether the host or the machine suffered an abrupt shutdown. Start the machine and then shut it down cleanly: the disk log will then be closed.
- Check how the machine is being backed up. Open the profile's
VSS componentsand see whether it is ticked under the Hyper-V writer.
Resolution
Back up a running machine using the Hyper-V VSS writer
The Hyper-V VSS writer (Microsoft Hyper-V VSS Writer) asks the guest machine to flush its memory to disk before the snapshot. This is the method to use for a machine that must remain powered on.
In the agent:
- Open the profile, then the source selection screen.
- Click
VSS components. The agent displays the list of VSS writers on the machine. - Expand the Hyper-V writer. Each virtual machine appears beneath it.
- Tick the machines to be backed up, then save the profile.
In the web interface, the same list is available in the agent configuration, VSS components section, via the Select components button. The agent must be connected for the list to be displayed.
If the
Disable open file backup (VSS)option is ticked in the agent's additional settings (in the web interface:Disable VSS,Diagnosticspage), the component list cannot be retrieved. Untick it first.
For the guest machine to respond to the writer, the Hyper-V integration services must be running inside that machine.
Back up a machine that is powered off
If the machine can be shut down during the backup, shut it down cleanly beforehand. Its virtual disk is then complete and its log closed. Reading the virtual disk file by file then produces a reliable backup.
Remove the virtual disk from the file copy
If the machine is backed up by the Hyper-V writer, remove its folder from the file selection, or exclude its .vhdx files. Otherwise the same disk is backed up twice, once of which via a file copy whose consistency is not guaranteed and which is not reported.
Special case: differencing disks
A Hyper-V checkpoint creates a differencing disk (.avhdx file). This disk contains only the differences from its parent disk. It cannot be read file by file on its own. The agent therefore backs it up in full, as an image, and reports this with a line of this type:
Virtual disk "…" backed up in image mode: Differencing disk: it describes only the differences…
For a machine that carries checkpoints, use the Hyper-V VSS writer. You can also merge the checkpoints before the backup.
If the problem persists
If the warning appears even though the machine is backed up by the Hyper-V writer and its folder is no longer in the file selection, contact BeBackup support. Please include:
- the name of the virtual machine and of the disk named in the message;
- the backup report;
- the list of VSS writers on the host, obtained with
bbAgent.exe -CommandLine -ListVssWriters; - the agent service log,
bbAgent-service.log.
BeBackup is backup built for IT service providers
Backup and restore of workstations, servers, virtual machines and Microsoft 365, encrypted at source with a key we do not hold, on the hosting of your choice.