How To: Properly Backup a VirtualBox Machine (.VDI)
November 18th, 2007 Posted in Computers/Tech, Fedora Linux, Linux, Ubuntu Linux
Most people don’t realize that making a backup of a VirtualBox Machine (.vdi) is more complex than just copy/paste. If you do that, you’ll soon realize (when it’s too late) that it doesn’t work! This is the proper way to backup your VirtualBox Machine:
VBoxManage clonevdi source destination
Example:
VBoxManage clonevdi ~/.VirtualBox/VDI/WindowsXP.vdi ~/WindowsXP_Backup.vdi
Then, wait for it to complete. It may take a while depending on the size of your .vdi file (or how much space you allocated towards your virtual machine).
Like the post? Did it help you? Want to thank me?
Buy me a soda!
Buy me a Lunch!
Help me in College!
November 18th, 2007 at 3:36 pm
[...] How To: Properly Backup a VirtualBox Machine (.VDI) [...]
December 18th, 2007 at 12:12 pm
It seems that the actual command is “VBoxManage” (without the final R).
December 21st, 2007 at 12:32 pm
Excellent, can you clone whilst a disk is in use?
December 21st, 2007 at 11:45 pm
@Gareth:
Good question. It’s too bad I don’t have a good answer for you. I could make something up, but that probably wouldn’t help out all that much.
Give it a try and see what happens.
January 1st, 2008 at 7:46 am
Thanks for posting this - it was very helpful.
January 24th, 2008 at 3:53 am
I just tried to clone a .vdi while it was in use, VBoxManage gives this error:
[!] FAILED calling virtualBox->OpenVirtualDiskImage(Bstr(argv[0]), vdi.asOutParam()) at line 2415!
[!] Primary RC = 0×80004005
[!] Full error info present: true , basic error info present: true
[!] Result Code = 0×80004005
[!] Text = Could not access hard disk image ‘/home/anthony/.VirtualBox/VDI/Windows_XP_20GB.vdi’ (VERR_FILE_LOCK_VIOLATION)
[!] Component = HardDisk, Interface: IHardDisk, {fd443ec1-000f-4f5b-9282-d72760a66916}
[!] Callee = IVirtualBox, {76b25f3c-15d4-4785-a9d3-adc6a462beec}
It worked just fine as soon as I powered down the virtual machine.
February 14th, 2008 at 6:34 pm
Hi there,
I simply want to duplicate a VBox machine. Searching the net I’ve found out about the standard solution
VBoxManage clonevdi Master.vdi Clone.vdi
and the (undocumented) function
cp Master.vdi Clone.vdi
VBoxManage internalcommands setvdiuuid Clone.vdi
which actually staffs the clone with a new SID in one step.
My problem is much less complex: how the hell do I get to the command line of VBox in Windows XP? Is it the Windows command line or do I have to run VBox in a special mode first?!
Thx for advice!
February 19th, 2008 at 10:49 am
I guess I’m not really sure what your question is…
Do you have an XP host or guest?
February 19th, 2008 at 1:31 pm
Hi derek,
it’s a WXP host and a WXP guest. And I want to clone the guest-VM.
Thx in advance…
February 22nd, 2008 at 1:00 am
In WinXP, you just need to open a command prompt, cd to the c:\program files\innotek directory and launch the VBoxManage command from there. You could also add the innotek prog files directory to your path if you wanted to run the VBoxManage from any directory.
February 22nd, 2008 at 10:07 am
Thanks Chief. I had no idea…
February 27th, 2008 at 2:06 pm
Thanks alot for the heads up!
makes the process of sysprepping a VM with this wonderfull application a breeze!
April 11th, 2008 at 8:31 pm
“Most people don’t realize that making a backup of a VirtualBox Machine (.vdi) is more complex than just copy/paste. If you do that, you’ll soon realize (when it’s too late) that it doesn’t work!”
Actually it does. Or at least it does for me (I didn’t know any better until I read here). On xp I just had to create a new machine using the same settings (probably the OS type is critical, not sure about the rest), and attach the copied vdi for its hdd. On linux it’s a little more complicated — you have to chmod the copied vdi.
Still haven’t figured out how to ‘flatten’ the snapshots so you get the latest version of your vdi though (and vboxmanage doesn’t do that either, AFAICT). I tried clonevdi with the uuid of the most recent snapshot, but vbm rejected that approach.
June 28th, 2008 at 8:20 am
I am experimenting too with backup of a live VBox VM. I know about the SID. But as David S pointed out, if you first delete the existing VM and create a new one pointing to the copied VDI, it will work. That is not the problem.
However, when I did a test, I advertently wrote to the disk of the VM while I was copying. That DID trash my copy, and this time it was not possible to start the copied VM.
It is logical that errors occur while copying a VDI that is written to, yet there seems to be quite some uncertainty about whether or not you can you cp to copy a VDI file.
I tried the clonevdi command as well, but this does requier the stopping of the VM, and that for many minutes while cloning a multi-GB file. That is not acceptable on a server.
Are there other experiences with copying a live machine?
I was using W2k guest on a Linux Debian Lenny host.
July 8th, 2008 at 6:15 am
test: clone vdi
October 3rd, 2008 at 9:55 am
I have the following problem: I’d like to backup an “intermediate” VirtualBox snapshot (i.e. there are other snapshots before and after the snapshot tree). The various information I was able to get my hands on was very confusing.
First of all: is it possible to back up a _snapshot_ at all? How would I go about to solve my problem? Any ideas?
Thanks!
October 10th, 2008 at 12:13 am
Cheers! thanks!
October 23rd, 2008 at 8:32 am
It works fine. But…
If you have .vdi file in a different directory you have to specified the complete path. And…
If this directory has spaces in name you have to use double cote (”).
E.G.
vboxmanage clonevdi “C:\Virtual Machines\ubuntu.vdi” “C:\Virtual Machines\ubuntu_clone.vdi”
October 27th, 2008 at 4:43 am
try a bat file in the folder where your vdi file is called someting like “clone.bat” with the contents being Start Quote:
ECHO off
SET original_name=”win2k.base.vdi”
SET copy_name=”w2k.1st.vdi”
SET vboxPath=”C:\Program Files\Sun\xVM VirtualBox\VBoxManage.exe”
SET options=”clonevdi”
ECHO on
%vboxPath% %options% %original_name% %copy_name%
(PAUSE)
:End quote. Good luck
November 1st, 2008 at 4:48 pm
[...] Some ramblings here might be useful: http://www.derekhildreth.com/ [...]
December 15th, 2008 at 4:26 pm
I have yet to discover a way to move/copy VM snapshot files from their original host directory to a destination host directory.
I’m in the situation where my host drive (C:) is nearly full because the VB snapshot files are so big!
I’d like to move the VB snapshot files off of the host drive (C:) and copy them to an external host drive (E: - 500GB), but VB provides the user/developer with no way to complete the task! Crazy!
December 18th, 2008 at 7:40 pm
I have Vista host and XP guest. I cloned a VDI file and only base OS copied to new VDI. All SPs of XP and applications installed on source VDI does not exist in the new VDI. The command used is: xboxmanage clonevdi old.vdi new.vdi. Anything I missed?
Thanks for your help.