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.