VMware Cloud Community
robertkwild
Enthusiast
Enthusiast

esxi free backup script to backup runing vms excluding some vms

hi all,

making a start writing a script and so far so good, just wanted to know all your thoughts really

 

#!/bin/sh

allvms=/scripts/allvms.txt
backvms=/scripts/backvms.txt

vim-cmd vmsvc/getallvms | awk '{ print $1 }' | awk '(NR>1)' > $allvms

while IFS= read -r line; do

vim-cmd vmsvc/get.summary $line | grep 'name' | awk '{print $3}' | grep -qw 'ldap'

if [ $? -eq 0 ]; then

sed -i "/$line/d" $allvms

fi

done < $allvms

cp -f $allvms $backvms

while IFS= read -r line2; do

name=$(vim-cmd vmsvc/get.summary $line2 | grep 'name' | awk '{print $3}' | sed 's/^[[:punct:]]//g' | sed 's/[[:punct:]]$//g' | sed 's/[[:punct:]]$//g')

vim-cmd vmsvc/power.getstate $line2 | grep -q 'Powered on'

if [ $? -eq 0 ]; then

echo $name

fi

done < $backvms

 

thanks,

rob

Reply
0 Kudos
1 Reply
e_espinel
Virtuoso
Virtuoso

Hello.
Maybe the following link can help you

https://www.virtuallyghetto.com/?s=GhettoVCB

 

Enrique Espinel
Senior Technical Support on IBM, Lenovo, Veeam Backup and VMware vSphere.
VSP-SV, VTSP-SV, VTSP-HCI, VTSP
Please mark my comment as Correct Answer or assign Kudos if my answer was helpful to you, Thank you.
Пожалуйста, отметьте мой комментарий как Правильный ответ или поставьте Кудо, если мой ответ был вам полезен, Спасибо.
Reply
0 Kudos