This post was most recently updated on December 11th, 2018
Earlier I wrote about Creating ESXi snapshot backups with ghettoVCB.sh. Now, the next logical step is to be able to automate these snapshots so you don’t need to ssh to the ESXi host and run the script manually and wait for the result.
We can use plink, and Windows Scheduled tasks to achieve this result.
In order to use Plink, the file plink.exe
will need either to be on your PATH
or in your current directory. To add the directory containing Plink to your PATH
environment variable.
Start -> Control Panel -> System -> Advanced -> Environmental Settings -> System Variables -> Path -> Edit, and enter the path for your plink.exe file.
OK, so once plink is setup correctly, you can use the following command to connect to your ESXi host, and set your script running with the appropriate ‘vmbackups’ file for the relevant machine.
E:\backup\putty\plink.exe root@10.6.40.36 -pw passsword “nohup /vmfs/volumes/datastore1/scripts/ghettoVCB.sh /vmfs/volumes/datastore1/scripts/vmbackupsbuilder > /vmfs/volumes/datastore1/scripts/backuplog.txt &”
Picking the above command apart:
1. E:\backup\putty\plink.exe (the path to plink.exe)
2. root@10.6.40.36 -pw passsword (the username, IP address and password of your ESXi Host)
3. “nohup /vmfs/volumes/datastore1/scripts/ghettoVCB.sh /vmfs/volumes/datastore1/scripts/vmbackupsbuilder > /vmfs/volumes/datastore1/scripts/backuplog.txt &” (this is the path to your ghettoVCB.sh file, the path to your vmbackups file, and a command to log the output
We also run this as a ‘nohup’ command so that the snapshot can continue without anyone being continuously logged into the host.
You probably want to run this without the nohup as a first test, to make sure everything is working OK.
Once you’re happy with the command and it runs successfully for you, you can simply add this command to a .bat file, and then use the standard Windows Task Manager to schedule it to run as frequently as you wish.