我想在对虚拟机进行集中备份之前集中删除 vMA 主机上的所有非活动快照。我希望已经有这样的脚本了??? 有人知道吗?
编辑:
以下是使用基本 vMA 工具完成该工作的脚本:
#!/bin/bash
#
# Purpose: List all snapshots for registered and powered-on VMs found on those
# ESXi hosts listed as VI Fastpass targets (vifptarget -l).
#
# Author: Ryan Bowlby
# VIFP ESXi hosts
esxi_hosts=$( /usr/bin/vifp listservers | awk '$2 ~ /ESXi/ { print $1 }' )
# Have to specify an esxi target before the "--server" opt works.
# http://www.virtuallyghetto.com/2011/01/how-to-automate-cron-vi-fastpass.html
first_esxi=$( echo $esxi_hosts | awk '{print $1}' )
source /opt/vmware/vma/bin/vifptarget -s $first_esxi > /dev/null 2>&1
for host in $esxi_hosts; do
reg_vms=$( /usr/bin/vmware-cmd --server $host -l 2>/dev/null)
for vm in $reg_vms; do
if /usr/bin/vmware-cmd --server $host $vm getstate | grep -q 'getstate() = on'; then
# print VM name (everything after last /) aka vm.split('/')[-1] ;)
vm_name="`echo $(basename $vm) | sed 's/\.vmx$//g'`"
#vm_name=$( IFS='/'; for elem in $vm; do echo $elem; done | tail -1 | sed 's/\.vmx$//g' )
echo $vm_name
if /usr/bin/vmware-cmd --server $host $vm hassnapshot | grep -q "1"; then
echo $vm_name has a snapshot, removing...
/usr/bin/vmware-cmd --server $host $vm removesnapshots
fi
fi
done
done