Backing up a VM

This is for discussing general topics about how to use VirtualBox.

Backing up a VM

Postby scottgus1 » 26. Jan 2012, 18:16

At the end of this FAQ (viewtopic.php?f=24&t=8046), TerryE suggests this prcedure for a backup:

"If you can’t take your VMs offline for long then one good trick is to start a new snapshot. Only the latest snapshot VDIs are opened R/W, so you can then backup the second to last whilst still using the VM. To resync, you savestate, delete the second last snapshot which in effect merges its content into latest; and resume the VM."

I have a question regarding this advice in the light of Virtualbox 4's keeping everything in one folder:

If I take a snapshot of a VM, copy the base VDI while the VM is running as suggested, then save-state, I could then copy the entire VM folder contents, except for the base vdi which has already been copied. My backup will then be a save-stated VM with one snapshot, theoretically being completed with the machine being off-line for much less time. I start the VM again, "delete" the snapshot, which merges the snapshot data back into the base vdi (while the VM is running, yes?) and I'm back up quickly.

Now, if my host dies and I reinstall Virtualbox on a new processor-compatible host, and I copy over that backed-up VM folder, will the new install of Virtualbox be able to recognize the save-stated, snapshotted VM and restart using the save-state, and then allow me to delete the snapshot into the base vdi as before? In other words, will the "restore" part of this backup process work?
running version 3.1.2, 3.2.12, 4.0.16, 4.2.16
Human government is like that crazy uncle who hides a quarter in his fist behind his back, then asks you to guess which fist the quarter is in.
No matter which side you choose, Left or Right, both Sides are empty.
scottgus1
 
Posts: 353
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: XP SBS2003 Win7

Re: Backing up a VM

Postby mpack » 26. Jan 2012, 19:28

I have to say that I don't much care for TerryE's suggestion - IMHO too tricky and possibly version specific. Plus of course it involves snapshots, and backing up VMs that are using snapshots, both of which I would want to avoid.

IMHO there are only two good, practical ways to backup a VM. One is using a live backup feature that runs inside the guest (backing up to a shared folder - otherwise a VBox crash would kill the backup as well!). The other is shutting down (not savestate) the VM, and copying the VM folder to a backup medium. I prefer the latter, because I personally have no need for a live backup, and because it's the most reliable method.
mpack
Site Moderator
 
Posts: 13129
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Backing up a VM

Postby Suncat2000 » 27. Jan 2012, 04:34

Unfortunately, I found out the hard way that you can't just copy the VM folder, at least with any not created completely from scratch with VB 4.0 or later. You also must copy the Snapshots and the .vbox metadata file to get the complete VM. If you don't, you will get only the base disk.

I know because my backup method was to clone the partition my VM was stored in. Except I found out too late that it was only one of three separate folder hierarchies created: one for the root disk, one for the differencing disks, and a third for the .vbox metadata, stored on different (host) disks. :evil:
Suncat2000
 
Posts: 3
Joined: 21. Feb 2011, 02:54
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows XP Pro

Re: Backing up a VM

Postby mpack » 27. Jan 2012, 10:27

I think you are describing the folder structure of v3.x or earlier - in fact I know you are. v4.0.0 introduced the new folder structure where everything belonging to a VM goes into a single folder - including the Snapshots subfolder and the .vbox file. In fact the .vbox file didn't exist at all prior to v4.0.0.

If you have a v4.x VM folder, and you copy the folder as intended, and do not fiddle around with individual files, then this will be a very complete and reliable backup.

[ Edit] If you don't have a v4.x VM, but you are now running VBox v4.1 or later, then cloning the VM creates a v4 folder layout for the clone [ but changes drive and VM UUIDs, which can cause problems ]. Alternatively you can do the v4 conversion manually, if you really know what you're doing.
Last edited by mpack on 27. Jan 2012, 17:01, edited 1 time in total.
mpack
Site Moderator
 
Posts: 13129
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Backing up a VM

Postby scottgus1 » 27. Jan 2012, 16:41

Thinking about it some more, mpack, after your first response, I agree. It's probably not a good backup solution. The saved-state condition of the backup includes whatever state the processor(s) were in when the save-state happened, which locks the backup to that processor or an identical replacement, which may not be available. Best way still seems to be a total shut-down of the VM. Or imaging software in the guest.

Thanks for the thoughts.
running version 3.1.2, 3.2.12, 4.0.16, 4.2.16
Human government is like that crazy uncle who hides a quarter in his fist behind his back, then asks you to guess which fist the quarter is in.
No matter which side you choose, Left or Right, both Sides are empty.
scottgus1
 
Posts: 353
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: XP SBS2003 Win7


Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 15 guests