Page 1 of 1

How to backup (and restore) virtual machines?

Posted: 3. Sep 2009, 20:37
by PerfectReign
I had a recent instance where I wanted to restore a Virtual Machine (Windows XP) that I'd created in VB 2.x on openSUSE to my current laptop running Ubuntu 9.04. I copied the .vdi file over from my backup hard drive, created the machine in VirtualBox (I'm on 3.0.4 currently), attached the .vdi to the machine and tried to boot.

Nada.

I searched and found that - basically the Windows hardware libraries would not load.

I went ahead and created a new VirtualMachine (XP) on my laptop and simply installed Windows XP from an old CD I have lying around. (This is to be used to do some programming in some older VB 6.0 programs that I am still supporting.)

Now that I have my XP machine up and running I want to back it up. Searching the intraweb, I see that simply copying the .vdi file doesn't work. I did see a thread here about backing up and a few other results which suggested either clonevdi or clonehd.

In either case, I get a nasty message that it can't register the hard disk.

Ideas?

kai@r2d2:~/.VirtualBox/HardDisks$ VBoxManage clonehd ./WindowsXP.vdi ~/WinXP_Backup.vdi
VirtualBox Command Line Management Interface Version 3.0.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

ERROR: Cannot register the hard disk '/home/kai/.VirtualBox/HardDisks/WindowsXP.vdi' with UUID {b974d9f6-a020-483e-8b75-2dd0f7337ce8} because a hard disk '/home/kai/.VirtualBox/HardDisks/WindowsXP.vdi' with UUID {b974d9f6-a020-483e-8b75-2dd0f7337ce8} already exists in the media registry ('/home/kai/.VirtualBox/VirtualBox.xml')
Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
Context: "OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam())" at line 624 of file VBoxManageDisk.cpp
kai@r2d2:~/.VirtualBox/HardDisks$




http://tuxtraining.com/2008/10/18/how-t ... achine-vdi

http://www.derekhildreth.com/blog/how-t ... chine-vdi/



http://forums.virtualbox.org/viewtopic. ... 07&p=94934

Re: How to backup (and restore) virtual machines?

Posted: 3. Sep 2009, 20:48
by Sasquatch
If you clone a hard drive, you don't have to specify the location of the original. That's why you get an error, it wants to register the source VDI first, but that's already done.

Now, for your error of the restoring backup, did you create the exact same settings as the original VM the VDI came from? Without that, Windows will barf at you and can fail to boot properly. So, if you backup a VDI, it might be wise to include a text file with the settings of that VDI (include the MAC addresses of the NIC(s) too).

Re: How to backup (and restore) virtual machines?

Posted: 3. Sep 2009, 23:15
by PerfectReign
Excellent idea on the text file.

Oddly enough, I simply copied THIS WindowsXP VM over to a Windows Vista machine (my laptop runs Ubuntu 9.04) and fired up VB. It worked just fine, with the exception of a networking issue that is related to our Active Directory.

Re: How to backup (and restore) virtual machines?

Posted: 4. Sep 2009, 10:32
by mpack
PerfectReign wrote:Now that I have my XP machine up and running I want to back it up. Searching the intraweb, I see that simply copying the .vdi file doesn't work.
On the contrary, a simple copy is exactly what you should use to make a backup, or to restore from the backup, or when moving a virtual hard disk to a different host. The only time a simple copy is wrong is if you want to copy a virtual HD and then register both at the same time, on the same host PC. That won't work because each hard disk has an internal signature called a UUID, and VBox application on the host doesn't like to see two virtual hard disks with the same UUID.
PerfectReign wrote:I did see a thread here about backing up and a few other results which suggested either clonevdi or clonehd.
Those commands are synonyms. "clonevdi" was the name of the original command. The command was changed to "clonehd" after the developers updated the feature to support cloning other virtual drive types (vhd, vmdk etc). The original command name is retained for compatibility.