Automating VMWare ESXi snapshots through Scheduled Tasks

July 7th, 2009

Earlier I wrote about Creating ESXi snapshot backups with 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 [email protected] -pw passsword “nohup /vmfs/volumes/datastore1/scripts/ /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. [email protected] -pw passsword (the username, IP address and password of your ESXi Host)

3. “nohup /vmfs/volumes/datastore1/scripts/ /vmfs/volumes/datastore1/scripts/vmbackupsbuilder > /vmfs/volumes/datastore1/scripts/backuplog.txt &” (this is the path to your 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.

One Response to “Automating VMWare ESXi snapshots through Scheduled Tasks”

  1. Gerard on April 6, 2011 11:15 pm

    The only issue with this you need a clear text root password to remotely execute the command.

    Im trying to use puttygen to create a public and private key set to get around this but for what ever reason the ESXi box is refusing my keys. Never had to get keys working for Windows to ESXi.

    I miss the days of stock standard ESX in which the host was just Linux.

Trackback URI | Comments RSS

Leave a Reply

Name (required)

Email (required)


Speak your mind