Requriments:

VMWare VCB

The scripts:

esxibkp.bat

@echo off
set bkppath=d:\
set scriptpath=c:\scripts
set vmpath=%bkppath%%1
set esxihost=ip.of.esx.i

echo %time% Backup of %1 started >> time.txt

cd C:\Progra~1\VMware\VMware~1\

rename %vmpath% %1-old
vcbMounter.exe -h %esxihost% -u root -p password -a name:%1 -t fullvm -r %vmpath% -m nbd >> log.txt

IF EXIST %vmpath%\*.vmx rd %vmpath%-old /s /q
IF EXIST %vmpath%\*.vmx echo %date% %time% Backup of %1 succeded >> %scriptpath%\succeded2backup.txt
IF NOT EXIST %vmpath%\*.vmx echo %date% %time% Backup of %1 failed >> %scriptpath%\failed2backup.txt
cd
echo %time% Backup of %1 ended >> %scriptpath%\time.txt

Changelog

Download

Usage:

Edit esxibkp.bat and put in esxihost, username, password and path-to-backupstorage.

run: esxibkp vmname

If you want to backup multiple VMs in one script, make a new bat-file. and type:

call esxibkp.bat vmname1

call esxibkp.bat vmname2

and so on…

Note1: Use these scripts with care, and dont blame me if they fuck something up ;)

Note2: The script does not support vm-names with spaces. I use vmname.domain.tld

Leave a Reply