I have a testing environment for our deployable application MSI here. It’s a licence of Windows XP running in a virtual machine courtesy of VirtualBox (I’m a big, BIG fanboy of free virtualisation). In essence, it’s a fully updated Windows XP environment with all the prerequisites loaded, ready for the MSI to be installed for the very first time. Whenever I want to convince myself that the MSI will install into a “new” XP environment, I can try it out. Once I’m satisfied, I can rewind back to a snapshot of a pristine environment. All Registry, GAC, User and/or application configuration mess disappears. Isolation testing when I can see before and after changes to an Operating system that hasn’t seen our application before has already delivered gold several times.
I’ve come to depend on this isolation testing approach so much that it’s time I got serious about backing up the virtual machine image. Now, I installed VirtualBox without thinking about backups initially. I’ve learned that by default, my virtual machine data is being written to my user “Documents and Settings” directory. It’d be a lot more convenient for my to have them under my D drive which is already set up for no-hassle backups of the development environment.
In my naivety, I thought it would be as simple as just copying the virtual machine directory from “Documents and Settings” through to my D drive. Doesn’t work. The virtual hard-drive image file is marked with a UUID that very tightly couples it to its virtual machine. I can’t even just change the file name without VirtualBox complaining long and hard that this is NOT the hard drive image it’s looking for.
After some frustration trying to get VirtualBox to use copied drives, virtual machines and snapshots, I gave up and consulted google. I tried (and tried) to follow the instructions here, but they failed me miserably. I really should have looked at the timestamp on this post. I finally read the entire, long comment history which lead me to gold. Things are much easier than they were back then, and I’ve just spent the morning jumping through rings of fire whilst whacking an angry bear with a foam bat, when I could have lazily told VirtualBox to just “Make it so, No. 2”.
The first thing I need to do is to export the currently selected virtual machine image via the menu item “Export Appliance…” thusly:
Then, I remove the image from VirtualBox (leaving the file structure intact, just in case it all goes pear-shaped) thusly:
Now, because I want all my VirtualBox shenanigans backed up, I change the default folder for new virtual images thusly:
I next import the saved virtual machine export, being guided by the import wizard (not shown):
And whallah, one moved virtual machine environment, sans the heartbreak required circa 2008:
Finally, a word of warning: The export will roll all your snapshots into one “current” one. If you’re in love with a deeply nested set of snapshots (like say, Windows straight of the install CD, then another with all the updates laid down, etc), they will be gone in your moved image.