Live export with snapshot

This is for discussing general topics about how to use VirtualBox.
Post Reply
alexlake
Posts: 20
Joined: 18. Jan 2018, 09:31

Live export with snapshot

Post by alexlake »

When a VM is running, one is not allowed to export it, as it's understandably a moving target.
However, if you take a snapshot, is there any way to export that (to a .ova file) while the current VM continues running and changing?
I can see that one might wonder why I should want to do such a thing - and the answer to that is testing out a potential new home for the VM without distutbing it/causing downtime.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Live export with snapshot

Post by scottgus1 »

When a snapshot is taken, the OS inside the VM doesn't know it, so the OS keeps writing, and you'll get half data and dirty, unprepared databases in the snapshotted copy.

On the other hand, when a 3rd-party backup app is run inside the VM OS, the OS can be prepared, such as through Windows' Volume Shadow Copy, or other such OS-specific internal mechanisms for doing live backups. Then the OS knows it's being backed up and can close/prepare databases, know what to do about open files, etc.

Rather than snapshot a VM and hope you have good data to copy/export, run a 3rd-party compatible backup app inside the VM, and send the image out through a real shared folder provided by an OS on the network, and restore the image into a VM at the destination Virtualbox host.

I don't believe that Virtualbox allows exporting part of a VM. But there are the snake-oil "snapshot-backup-a-live-VM" routines that various uninformed individuals have hawked on the forum and other websites. Just be aware that the OS inside the VM will interpret the data generated by such a routine as if the OS was unceremoniously power-cut, not properly shut down, and some OS's & data really don't like that.
alexlake
Posts: 20
Joined: 18. Jan 2018, 09:31

Re: Live export with snapshot

Post by alexlake »

So does that not mean that snapshots themselves are dangerous? i.e. if you rollback, is that going to be safer?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Live export with snapshot

Post by scottgus1 »

Snapshots do make a VM more delicate. But they're not dangerous in themselves, as ling as the host is solid and the actual snapshot disk files aren't footled with.

The theory behind Virtualbox's snapshot system is sound, but I believe that VMs that contain important data shouldn't be snapshotted, because there is a risk that something could go wrong. The forums are replete with folks having trouble because they did something wrong or a problem happened with their commodity PC hardware.

A snapshot while the VM is shut down allows the VM to start in a fully shut down state, where all the data that needs to be saved to disk has done so.

A snapshot while the VM is running contains a saved state file that allows the unsaved data to be saved and restored when the snapshot is restored. Saved states don't always survive a Virtualbox version change, so there is that risk.

There could be a way to cobble together a copy of the save state file and the other disk files on a VM after a snapshot-based "backup attempt", but there is no Virtualbox method to make this happen. It would require manual writing of a .vbox file, and you could only use it on the original host, since saved states can't migrate to other hosts. I think exporting is not compatible with saved states, either.
alexlake
Posts: 20
Joined: 18. Jan 2018, 09:31

Re: Live export with snapshot

Post by alexlake »

Very interesting. Thanks for taking the time to write all that!
Post Reply