Backing up a vmware virtual machine
I’ve learnt quite a number of new things today. One of these things is that an ISO9660 filesystem doesn’t allow files bigger than a couple of gigabytes. Another thing is that bzip2 kicks ass, even if it actually doesn’t implement the best compression algorithm available today (your milage may vary).
Another interesting thing is that the good old cdrtools package on Gentoo sucks. In my understanding that’s mainly because of licencing issues which came out during the software development. But, no worries, the new cdrkit ebuild has a modern cdrtools implementation with a compatible interface. That is, the good old mkisofs and cdrecord command lines you (and your GUIs) had learnt how to use are just the same. Different software, same interface. Great, uh? So, first of all, if you want the latest tools on a Gentoo box, you’ll need to:
# emerge -C cdrtools
# emerge -av cdrkit
Anyway, my job today was to backup on DVD-R media a large vmware virtual machine in order to regain free storage space on a server with serious shortage troubles. To begin with, we have a directory which holds the VM (virtual machine) files:
# du -sh my-very-cool-vm
21G my-very-cool-vm
Now, 21 gigabytes of data is a lot because this VM hosts a few extra virtual disks. But, if you’re lucky enough like me, some bzip2 goodness might help:
# tar cvf - my-very-cool-vm | \
bzip2 --compress --verbose --best --stdout > \
my-very-cool-vm.tar.bz2
# ls -lh my-very-cool-vm.tar.bz2
total 4.3G
-rw-r--r-- 1 root root 4.3G Mar 8 15:32 my-very-cool-vm.tar.bz2
Depending on your iron, the time between tar and ls might be enough for you to gain a few extra golds in World of Warcraft. Anyway, now that might actually fit on a DVD-R. But, since there’s a 2GBytes file size limit on ISO9660 filesystems, we still need to do a little something before we can fire up mkisofs. Our old unix friend split comes to the rescue:
# split -b 1024m -d my-very-cool-vm.tar.bz2 \
my-very-cool-vm.tar.bz2-part-
# rm my-very-cool-vm.tar.bz2
# ls -lh
total 4.3G
-rw-r--r-- 1 root root 1.0G Mar 8 16:04 my-very-cool-vm.tar.bz2-part-00
-rw-r--r-- 1 root root 1.0G Mar 8 16:05 my-very-cool-vm.tar.bz2-part-01
-rw-r--r-- 1 root root 1.0G Mar 8 16:05 my-very-cool-vm.tar.bz2-part-02
-rw-r--r-- 1 root root 1.0G Mar 8 16:06 my-very-cool-vm.tar.bz2-part-03
-rw-r--r-- 1 root root 295M Mar 8 16:06 my-very-cool-vm.tar.bz2-part-04
This is just perfect. Assuming the above files are in a directory called mydir, I can now run mkisofs like this:
# mkisofs -o dvd.iso -r mydir
This creates a file which holds the ISO9660 filesystem that we can later feed to cdrecord. My peculiar incantation for cdrecord is as follows:
cdrecord -v dev=/dev/hdc driver=mmc_mdvd -sao dvd.iso
[...] effetti, fare un backup su dvd di una virtual machine su un server linux non e’ molto diverso da picchiare un gruppo [...]
Nexse Portal » Karmageddon
March 13, 2007 at 12:25 pm
You could just do
tar c –use-compress-program=”bzip2 -9″ my-very-cool-vm | split -b 1024m – my-very-cool-vm.tar.bz2-part-
And if the resulting tar.bz2 is under 4.3GB you can just
tar c –use-compress-program=”bzip2 -9″ my-very-cool-vm | cdrecord dev=/dev/hdc -
(To extract that: tar xvjf /dev/hdc)
v
March 13, 2007 at 3:47 pm
are hot backups supported in VMWARE? i.e. if i copy the virtual machines directory while it is running, what happens?
James
April 13, 2007 at 8:36 am
Hmm, I don’t think that’s a good idea. You’d have to at least suspend the virtual machine before making your backup. If you have a journaling filesystem inside your virtual machine, it might work but I wouldn’t rely on such a kind of hot backup. I’d stop the VM, then make the backup.
What I know is that you have some sort of “snapshot” feature in vmware. From what I understand, it should work by pressing a “snapshot” button so that you can later tell the software to “go back to snapshot X”. But I’m not sure how the snapshot feature interacts with the kind of hot backups you’re talking about.
mcaserta
April 13, 2007 at 12:33 pm
Best Practice for Backing up Virtual Machines
After reviewing a brief article which asks more questions that it answers over at techtarget. “The best way to back up a virtual machine” I really thought about how a medium to large company does backups on their physical network and realiz…
x86 Virtualization
October 3, 2007 at 4:30 pm