ghettoVCB icon indicating copy to clipboard operation
ghettoVCB copied to clipboard

only backup running vms and size of backup folder

Open robina80 opened this issue 3 years ago • 1 comments

hi all,

just couple of questions about ghetto VCB, i know you can either install the vib or offline version, whats the difference, is it that the vib needs internet to download where as the offline bundle doesnt?

i know you need to edit the conf file but i dont see anything about

vms to exclude from backup

only backup running vms

how big i want the backup room/folder to get until it starts to overwite old vm backups

thanks,

rob

robina80 avatar Mar 22 '22 10:03 robina80

i made this script ages ago, tested it a few times on my home lab and it worked

made it excluding vms and only backup running vms

`#!/bin/sh

allvms=/scripts/allvms.txt backvms=/scripts/backvms.txt vmdks=/scripts/vmdks.txt source=/vmfs/volumes/datastore1 dest=/vmfs/volumes/datastore1/backup date=$(date +%d-%m-%y)

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 'centos7'

    if [ $? -eq 0 ]; then

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

    fi

    vim-cmd vmsvc/power.getstate $line | grep -q 'Powered off'

    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/[",]//g')

    mkdir -p $dest/$date/$name

    cp -f $source/$name/$name.vmx $dest/$date/$name/$name.vmx

    vim-cmd /vmsvc/snapshot.removeall $line2

    grep -w 'vmdk' $source/$name/$name.vmx | awk '{print $3}' | sed 's/[",]//g' > $vmdks

    vim-cmd /vmsvc/snapshot.create $line2 $name-ss $name-ss 0 1

            while IFS= read -r line3; do

                    vmkfstools -i $source/$name/$line3 $dest/$date/$name/$line3 -d thin

            done < $vmdks

    vim-cmd /vmsvc/snapshot.removeall $line2

done < $backvms`

robina80 avatar Mar 22 '22 13:03 robina80