My lab environment is more and more important for some of my daily tasks. But I do not care about the system itself. The only requirement is that it has to run. but as it get’s more and more important I started thinking about a backup. ESXi has no built-in function for this and external tools are mostly expensive, for a lab system. But I found a small tool to backup ESXi server, which is free of charge and works like a charm. But let’s start with the beginning.
Currently, I have two ESXi servers in my lab. They run stuff like AirWave, ClearPass, Active Directory, my Mobility Master and a DNS/DHCP server. All my clients need this infrastructure to get access to the lab and the internet. If the ESXi server fails or one of the VM’s get corrupted, the manual recovery will consume a lot of time. So I start looking for a simple backup solution. I have a Synology Disk Station in the lab. My intention is to use the Disk Station for the backups.
The first search offers many tools, but most of them are either expensive and for real production environments or nasty scripts. But some blog posts recommend ghettoVCB from William Lam. He is with VMWare and his tool looks quite promising. There is already the option to use an external NFS store for the backup. And the backup is an online backup. Just what I was looking for, for my lab.
I use the vghetto-ghettoVCB.vib file. I also download the latest version of the ghettoVCB.sh file. This file contains some extra fixes for NFS and ESXi 6.5.
The “TSM-SSH” service is the ESXi SSH server. The SSH server should start with the host. Afterward, you can start the service. In my case, it is already running.
My configuration is very simple. The important part is the NFS section. This configures the NFS store. The “NFS_LOCAL_NAME” and the NFS_VM_BACKUP_DIR” are two parts of the “VM_BACKUP_VOLUME” option.
Check the upper part. You should find all your configurations here. If one is missing, check the configuration file again, and rerun the script.
Finally, the script should run automatically. In Linux, there is cron. In ESXi, you can use cron as well. It is just not that easy as with normal Linux distributions.
You could simply add the script to the crontab of root. But this modification is gone after rebooting the ESXi server. To make it more sustainable, I use a script during boot of ESXi. The script simply stops the cron daemon, insert the cronjob to the crontab file and restart the cron daemon again. This works for ESXi version 6.5. For older versions, you should check, how to permanently add a cronjob as the precedure might differ.
The script added the last line. My script runs every 15th at 5am in the morning. You can, of course, adjust the timing to your needs.
Let’s assume I never need this. But if something goes wrong the recovery is simple. The only pitfall, there are some more manual steps as during the backup.
The first command adds the NFS store to the ESXi server. The second one is just to confirm it is mounted.
Restoring VM to Datastore: "/vmfs/volumes/datastore1/" using Disk Format: "zeroedthick"
The VM is restored and registered to the ESXi server. You just need to start the VM again.