Backup your linux (Debian) virtual machines (VMWare)
In the last post I wrote about a free NAS solution for you home (or office) backup strategy. I wrote about the ease of setting it up and how I searched for a free and simple way to backup my windows machines. I am stil using GFI Backup 2009. The only change is, that I am storing my last 3 complete backups instead of incremental backups. The reason for that is, that I feel more secure this way. If the last backup is corrupted I still have two good backups and I do not have to worry how I will put the increments back together.
Now I would like to show, how I made the backups of my virtual machine. The host is Debian OS (Lenny) and on top of that I have a VMWare server 1.0.9 with several virtual machines running inside. The beauty of this is, that in order to backup the data, I just need to backup the whole virtual machine. No complicated plans and scripts to backup databases, SVN repositories etc. Just stop the virtual machine (you have to stop it first as it is the safest way and the data is not corrupted if you do this) and tar the whole directory to the NAS. In the beggining I had and idea of using rsync to do incremental backups, but I changed my mind. I just followed the windows phlosophy. Store the last three backups of every virtual machine and that is it. This is how I did it.
As I already have a Samba share configured on the NAS I just installed the Samba client
apt-get install smbfs
then i added the Samba client to modules
echo 'smbfs' >> /etc/modules
and to fstab, so it will be mounted on each boot
//NASServer/backups /mnt/backups smbfs defaults,user,password= 0 0
I did not need username and password because NAS in protected only by IP’s that can connect to it. Because I have it behind a router and a firewall, inside LAN and I am the only one using it, there is no need for any other protection. Now all that is left, is the script to backup VM machines on a weekly basis. I tried using ZIP at first to compress them, but found out that it cannot handle files larger that 2GB, so I swithed to TAR. This is the script
# # Backup the virtual machines of choic to a samba share # CurrentDate=`date +%y%m%d` vmrun stop "/var/vm/Ubuntu 7.10 Server/Ubuntu.vmx" tar -cvvf /mnt/backups/CROMIS/VM_Cromis_$CurrentDate.zip "/var/vm/Ubuntu 7.10 Server" vmrun start "/var/vm/Ubuntu 7.10 Server/Ubuntu.vmx"
This is the sample of a single VM being archive. What is missing is the rotation of the last 3 backups, but that I still have to implement. No a big deal though. So in short this is it. Simple and efficient. But I would like to point out two problem I encountered on the way to this solution and are both related to the new Lenny Debian distribution.
The first problem is that they changed the default ehternet interface from eth0 to eth1. I don’t know who has this “brilliant” idea, but it took me a lot of time to figure out why I can’t connect to my server anymore. I will show the way to upgrade between stable releases in the next post, bust let me just say that changes like that are not very smart. And the other problem was that VMWare server was not working anymore with the new 2.6.24 kernel. I tried everything, but could not make it work. I managed to rebuild the VMWare core modules with the WMVare-any-to-any-update patches, but the VM machines wouldn’t start anymore. So I was forced to go back to 2.6.18 version of the kernel. There all is fine. Why don’t I upgrade to WMVare server 2.x you wonder. Because the removed the console and left us with java bloated web interface that uses Tomcat. I read a lot of negative reviews and I am not prepared to change my smooth working 1.0.9 version.
Edit: I now use 7zip on top of the tar archives as this greatly reduces the size of the archived files.
tester321 wrote,
Very useful info, thank you! Some questions:
1) Is Samba the fastest copy method? (It is definitely easy to setup.) Check here for an interesting thread on copying vms quickly:
http://bit.ly/Fast_vmware_network_copy
2) So, you ended up “downgrading” back to Etch, correct? I am curious because IIRC 2.6.18 is Etch and I have not found anyone yet who successfully has VMware Server 1.0.9 running on Lenny.
PS: I am running VMware 1.0.9 for the EXACT reasons you are.
Thanks
Link | November 3rd, 2009 at 8:35 am
Iztok Kacin wrote,
1) I am sure Samba is not the fastest method. But as you said it is easy to setup. For now I do backups once a week (on the night from sunday to monday) and the VMs are small so speed is not an issue. But I will look at the link you provided. Thanks a lot.
2) Yes, there is no way (at least that I know of) to run VMware Server 1.0.9 on Lenny. I downgraded just the kernell at the time, but kept the sources pointing at Lenny distro. I use apt-pinning as written in my other post and that makes a very flexible setup.
But I was forced to go back to the newest kernel and thus to WMware server 2.0.1 for two reasons.
1. I upgraded my server with quad core proc and a new motherboard (with 8GB of RAM). The old kernel would not boot any more with the new setup, but the new one worked without problems. So I decided I do not have the time to do a complete reinstall and went for VMware 2.0.1. Even this one does not work without some patching. Few days ago 2.0.2 came out but I was dissapointed. Half a year or more and they did’t do anything relavant.
2. In the long run it is a lost battle, to try and stay on old kernel and old VMware. But for now if you can stay on 1.0.9 stay there. 2.0.1 is not stable enough.
I am seriously contemplating going for ESXi, but for now I do not have the correct hardware for it. Oh, by the way you can avoid the horrible web management in 2.0.1. I downloaded the 2.0.0 release which has the VI infrastructute client hidden inside (the same that ESX uses) and that is a great tool
Link | November 3rd, 2009 at 8:53 am
tester321 wrote,
Excellent info again. Yes, I am in the same dilemma, re: VMware …
1) I *love* Debian as a “host” OS — tried other distros, SUSE 9.x – 10.3 in particular … but I keep coming back to Debian. I have even used it on various thin client “appliances” that I build; it is perfect for this!
2) I *love* VMware but they *really* screwed up on 2.0 IMHO; especially with that bloated console.
So, I am trying to ride this VMware 1.0.9 + Debian Etch as long as humanly possible. FYI, I just confirmed that Lenny works perfectly as a Guest VM under 1.0.9 + Etch as a Host.
From what I hear, many suspect ESXi is just some stripped down Linux, but we won’t know unless a GNU licensing challenge is made. I want a “real” OS as my Host … even if it robs me of a little performance.
What is sad is that there is a 5 yr old (and still active) thread on their site ( here: http://bit.ly/freebsd_vmware_host ) asking for FreeBSD as a host … now THAT would be super interesting!
Link | November 3rd, 2009 at 10:58 am
Iztok Kacin wrote,
I love Debian too. Tried some other distributions, but came back to Debian quickly. It is stable, robust (never failed on me) and I know my way around inside (at least as much as I need). So for me it is a no brainer
I don’t know about ESXi. From what I heard it is pure HW virtualization. ESX has Linux inside that runs some services and the web console I think, but ESXi is supposed to be barebone. Which is ok I suppose. The only downside for me is, that I have no OS underneath then. I feel more comfortable with OS underneath so I can make simple backups and do other maintainace tasks. I lose a layer that way, but yes I gain on speed. Anyway ESXi is pretty picky when it comes to hardware and I have no intention on buying expensive certified server.
My main work is on Windows platform, this is what I do for a living. Linux is my steam release valve. I love playing with it to get away from windows for a while and I also have a virtualization layer for testing and development
BDS would be nice to see, but I doubt this will happen
Thanks for the links and the feedback, it has been most educative. I hope you can ride your 1.0.9 version of VMware until they make something better then 2.0.1
Link | November 3rd, 2009 at 2:04 pm
tester321 wrote,
Totally agree (re: wanting a “real” OS as my VM host). And I ONLY run Windoze under a VM … sick & tired of its moodiness as the “host” OS on top of my hardware, lol.
I “tinker” with all kinds of stuff … hardware and software … but do Information Security for “real” work.
Thanks for all the great info and discussion!
Link | November 17th, 2009 at 4:23 pm
From Zero To One » Blog Archive » What do you do when your VMware server dies? wrote,
[...] virtual machines are backup-ed regularly to the NAS machine. I have written about that a while ago here and [...]
Link | January 10th, 2010 at 12:27 pm