| Subcribe via RSS

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!

22 Responses to “How To: Properly Backup a VirtualBox Machine (.VDI)”

  1. How To: Install VirtualBox on Fedora 8 (Werewolf) « SendDerek’s Blog Says:

    [...] How To: Properly Backup a VirtualBox Machine (.VDI)  [...]


  2. maumac Says:

    It seems that the actual command is “VBoxManage” (without the final R).


  3. Gareth Says:

    Excellent, can you clone whilst a disk is in use?


  4. sendderek Says:

    @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.


  5. Neil Says:

    Thanks for posting this - it was very helpful.


  6. Anthony A. Says:

    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.


  7. Media Addicted Says:

    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!


  8. sendderek Says:

    I guess I’m not really sure what your question is…

    Do you have an XP host or guest?


  9. Media Addicted Says:

    Hi derek,

    it’s a WXP host and a WXP guest. And I want to clone the guest-VM.

    Thx in advance…


  10. BigFunkyChief Says:

    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.


  11. sendderek Says:

    Thanks Chief. I had no idea…


  12. Avi Says:

    Thanks alot for the heads up!
    makes the process of sysprepping a VM with this wonderfull application a breeze!


  13. David S Says:

    “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.


  14. Hans Linkels Says:

    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.


  15. j. rose Says:

    test: clone vdi


  16. david Says:

    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!


  17. Akshat Says:

    Cheers! thanks!


  18. Fernando Says:

    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”


  19. Dan Says:

    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


  20. Simkin’s Musings » Blog Archive » VirtualBox Rides again Says:

    [...] Some ramblings here might be useful: http://www.derekhildreth.com/ [...]


  21. Paul Says:

    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!


  22. Jason Says:

    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.


Leave a Reply

  • Polls

    Should I Branch Off DerekHildreth.com?

    View Results

    Loading ... Loading ...
  • Feeling Generous?