Page 1 of 1
Migrating snapshots
Posted: 12. May 2014, 09:14
by Secspert
Hi I've got a VM that I always want to start from a pre-defined snapshot. I have created the snapshot with VBoxManage and I can also reset the VM to that state and start it from that state. So basically, that all works. However now I want to migrate that snapshotted VM to another physical machine, and I cannot figure how to do that with VBox. Usually I export VMs as OVA using the VBox tools, but when I do that with the snapshotted VM, I loose all snapshot information. Is there a smart way to migrate a VM with all its snapshots, or maybe even just with a set of selected snapshot? In my case I even just need a single snapshot. I have read about copying the complete directory of the VM, but that seems like a pretty rough approach, and I was wondering if there were smarter tools to do this?
Cheers for any pointers!
Re: Migrating snapshots
Posted: 12. May 2014, 09:19
by loukingjr
Copying the VM's folder is the easiest way and no doubt the fastest if you want to preserve the snapshot structure. it's also probably the only way.
Re: Migrating snapshots
Posted: 12. May 2014, 09:22
by Secspert
What if I didn't care about the structure, and just needed a single snapshot (basically, the first one created)? Would that allow other ways of doing it?
Re: Migrating snapshots
Posted: 12. May 2014, 09:36
by loukingjr
Secspert wrote:What if I didn't care about the structure, and just needed a single snapshot (basically, the first one created)? Would that allow other ways of doing it?
I don't use snapshots. however, if I remember the users manual, if you go into VirtualBox>snapshots with the guest not running. and select the snapshot you want to keep. then click restore snapshot, all the snapshots and changes to the guest that were done after that snapshot will be thrown away. But you still have to preserve the structure so you are back to copying the VM folder.
Re: Migrating snapshots
Posted: 12. May 2014, 12:14
by mpack
Secspert wrote:What if I didn't care about the structure, and just needed a single snapshot (basically, the first one created)? Would that allow other ways of doing it?
This seems to reverse the question in your OP. If you don't care about preserving the snapshot structure then surely you can use export.
Another way is to select the desired snapshot and then clone the VM without preserving the snapshot structure. Then copy the clone VM folder to the new host. This has the advantage of not converting all the drives to VMDK format.
Re: Migrating snapshots
Posted: 12. May 2014, 12:40
by Secspert
Maybe what I need is actually not well solved with snapshots. Basically I want to be able to start a specific VM ( in running state ideally!! ) from the same state on multiple physical machines. I don't really need to preserve any state from that VM - it is ALWAYS supposed to start from that single, initial state. So probably, as I'm reading through VBox documentation, an immutable disk image might be the right solution to this? I guess that it would be exportable, and it would keep the initial state no matter what?
Could I, for example, save the initial, running state from my VM, then make the virtual disk immutable, then export the VM, and then resume it on multiple host from that same initial state? And from then on, whenever I shutdown and re-start the VM again, it would always start from that clean disk space, right? The only thing I cannot do without snapshots I guess is re-start a VM all the time in "running" state. Basically, I want to prevent having to EVER boot the VM once it has been snapshotted and marked as immutable. I want to be able to always start it in a running state, from the same immutable disk image. I guess it needs a combination of snapshotting and immutable disks?
Re: Migrating snapshots
Posted: 12. May 2014, 13:02
by Martin
There is no (easy) way to transport a saved state ("running VM") to another PC.
If you would manage to transfer all needed files and settings you still wood need exactly identical PCs as a saved state contains very processor and hardware specific values.
Also Virtualbox provides no way to "keep" a save state when you start a guest from there, so you would need to copy all necessary files back before each start.
Re: Migrating snapshots
Posted: 12. May 2014, 13:07
by loukingjr
Secspert wrote:Maybe what I need is actually not well solved with snapshots. Basically I want to be able to start a specific VM ( in running state ideally!! ) from the same state on multiple physical machines. I don't really need to preserve any state from that VM - it is ALWAYS supposed to start from that single, initial state. So probably, as I'm reading through VBox documentation, an immutable disk image might be the right solution to this? I guess that it would be exportable, and it would keep the initial state no matter what?
Could I, for example, save the initial, running state from my VM, then make the virtual disk immutable, then export the VM, and then resume it on multiple host from that same initial state? And from then on, whenever I shutdown and re-start the VM again, it would always start from that clean disk space, right? The only thing I cannot do without snapshots I guess is re-start a VM all the time in "running" state. Basically, I want to prevent having to EVER boot the VM once it has been snapshotted and marked as immutable. I want to be able to always start it in a running state, from the same immutable disk image. I guess it needs a combination of snapshotting and immutable disks?
You can't do what you want to do. If you had mentioned what you actually wanted to do, you could have been told that already.
Re: Migrating snapshots
Posted: 12. May 2014, 13:11
by Secspert
Yes I can. It does already work by just copying the complete VM folder including the snapshots. It works perfectly fine. I was just looking for an optimization.
Re: Migrating snapshots
Posted: 12. May 2014, 13:13
by loukingjr
Secspert wrote:Yes I can. It does already work by just copying the complete VM folder including the snapshots. It works perfectly fine. I was just looking for an optimization.
smh

Re: Migrating snapshots
Posted: 12. May 2014, 13:25
by Secspert
Martin wrote:There is no (easy) way to transport a saved state ("running VM") to another PC.
If you would manage to transfer all needed files and settings you still wood need exactly identical PCs as a saved state contains very processor and hardware specific values.
Also Virtualbox provides no way to "keep" a save state when you start a guest from there, so you would need to copy all necessary files back before each start.
I know for sure that I always deploy on the same hardware, so that's not a problem at all. I also know I always have the same version of VBox, same configuration, and so on.
If I copy the VM folder to a new machine, then do a "VBoxManage snapshot $vm restore $snapshot" and then do a "VBoxManage $vm start", it does seem to work OK.
Does anyone know if it is cheaper to use immutable disks than snapshots, or is it implemented in the same way under the hood?
Re: Migrating snapshots
Posted: 12. May 2014, 13:28
by Secspert
mpack wrote:Secspert wrote:What if I didn't care about the structure, and just needed a single snapshot (basically, the first one created)? Would that allow other ways of doing it?
This seems to reverse the question in your OP. If you don't care about preserving the snapshot structure then surely you can use export.
Another way is to select the desired snapshot and then clone the VM without preserving the snapshot structure. Then copy the clone VM folder to the new host. This has the advantage of not converting all the drives to VMDK format.
I'm only concerned about a single snapshot. Not the whole tree. That's what I meant to say.
Your second advice might be an option.
Re: Migrating snapshots
Posted: 14. May 2014, 15:51
by noteirak
Immutable disks and snapshots use the exact same function under the hood :
a base disk which became immutable, and a diff disk to store the changes.
The differences are :
Snapshot is about the VM config and all its disks (unless configured otherwise) that are made immutable, and is persistent.
Immutable disk is only that disk which is configured as such, and its diff disk is reset at each power off of the VM.
It all depends if you want to keep a single disk immutable (like the OS one) while having another disk for user data, or if you want a machine to revert exactly to a specific state - VM config + all its disks.
Depending on your answer, you'll need different things.