Like many others that work with the free version of ESXi, I think VMware should have included an easy way to backup virtual machines even if it was just a copy to another Datastore.
Knowing that backups are extremely important, I have looked all over trying to find a simple and free way to backup the free version of ESXi Server. I finally found one that works well and was not that difficult to setup.
Backups can take a lot of time so to avoid any downtime it is best to schedule them to run at night.
- This backup solution requires that the backup computer have the VMware VI Remote CLI for Windows installed
- Enough hard drive space on the target backup PC to store the virtual machine backups
- ESXi-backup.pl - I found the backup script on the VMware Communities site.
You must modify ESXiBackkup.pl to work in your environment. It's not hard to do, it can be opened with any text editor, I used Notepad. I had to remove some extra lines from the script that caused problems for me so hopefully they won’t cause any problems for you.
Below I’m going to take you through the configuration portion of the script. I'm only going to show you the pertinant information. To help with any formatting issues I'm going to have the script information surrounded in blue. The changes will be in standard text.
my $url = https://IP-Address:Port/sdk/vimService
Change "IP-Address:Port" to the IP address or hostname of your Server
my $username = "user";
Replace "user" with the root user for your ESXi Server.
Replace "pw" with the root password for your ESXi Server
my $DSPath = "[datastore]";
[datastore] needs to be replaced with the name of the datastore you want to backup. You need to include the brackets  or the script will not work.
$VMNames = "ServerDisplayName";
Replace ServerDisplayName with the name the way it is Displayed in the VI Client. If you want to backup more than one VM put the name between the quotes of the next openVMNames[#]
You must add the path the the VI Remote CLI Path. This can only be in the Windows short file name format. The default should work but if it does not you can type "dir /x" from a command window in the c:\program files\vmware directory.
my $DestPath = "D:/esxi-backups";
The last step before running the backup script is to make sure you have all of the directories created that you may need. In the destination path you need to create directories for each VM that you wish to backup. In the case of this example we need to make sure we have a directory called "ServerDisplayName" in D:\esxi-backups. If we don't the backup will fail.