Skip to content

Create snapshot on multiple VMWare vSphere ESX virtual machines

I wrote a simple script which creates a snapshot on multiple machines. This can also be used to delete snapshots on multiple machines. You’ll need vmware SDK for perl and an answer file with IPs separated by a carriage return like:
192.168.1.100
192.168.1.101

Then use this script:
#!/bin/bash
API_User=administrator
API_Password=INSERT_PASSWORD
snapshotName=test
answerFile=./answerFile.txt
destinationFile=/var/www/default/htdocs/SnapshotsCreated.txt
date >> $destinationFile
echo ” ” >> $destinationFile
for machineIP in `cat $answerFile`
do
echo ” ” >> $destinationFile
echo “##### “$machineIP” #####” >> $destinationFile
/usr/lib/vmware-viperl/apps/vm/snapshotmanager.pl –url https://myVirtcenter.myCompany.com/sdk/vimService –username $API_User –password $API_Password –IPaddress $machineIP –operation create –snapshotname $snapshotName >> $destinationFile
echo ” ” >> $destinationFile
date >> $destinationFile
exit 0

Post a Comment

You must be logged in to post a comment.