ESXI FREE 6.5.0 backup using ghettoVCB sh https://youtu.be/92Q42tfNHuc

ESXI FREE 6.5.0 backup using ghettoVCB sh Update 1 https://youtu.be/yqB6awYInFw


Setup ghettoVCB

As of 02-03-2018

NOTICE: VMFS6 (Virtual Machine Version 11) or newer will not delete prior snapshots. This will cause an issue when restoring vms later. I have a fix below for this. _

NOTICE: Though I provide this version of the script you have the choice to update to the latest version Here. Also note that I don't own this file simply posting the version that was available at the time of creating the youtube videos above.

All credits go to the original creator: Here is his GitHub Page.

  • William Lam
  • lamw

Getting Started

Install Debian 9 or later.

Setup Debian with no standard user just a root account will do!

mkdir /home/script/
mkdir /home/script/MOVE-TO-ESXI

Download each file needed for Debian below.

cd /home/script/
wget https://sesipod.info/DATA_FILES/ESXI/ghettoVCB/backup.txt
wget https://sesipod.info/DATA_FILES/ESXI/ghettoVCB/runme.sh

Download each file needed for ESXI below.

cd /home/script/MOVE-TO-ESXI
wget https://sesipod.info/DATA_FILES/ESXI/ghettoVCB/ghettoVCB.sh
wget https://sesipod.info/DATA_FILES/ESXI/ghettoVCB/vms_to_backup

Setup backup.txt

nano /home/script/backup.txt

Change the following lines:

  1. cd /vmfs/volumes/DRIVEtoUSE/BACKUP-SCRIPT
    • Change DRIVEtoUSE to the Datastore you want to use for backups.

Setup runme.sh

nano /home/script/runme.sh

Change the following lines:

  1. sshpass -p 'esxiPW' ssh -o StrictHostKeyChecking=no [email protected] < /home/script/backup.txt
    • Change esxiIPaddress to the ip of your ESXI server.
    • Change esxiPW to the password of your ESXI server.

Setup ghettoVCB script

nano /home/script/MOVE-TO-ESXI/ghettoVCB.sh

Change the following lines:

  1. VM_BACKUP_VOLUME=/vmfs/volumes/DRIVEtoUSE/BACKUP-VMS
    • Change DRIVEtoUSE to the Datastore you want to use for backups.
  2. DISK_BACKUP_FORMAT=
    • Set this to Thin to save space on the destination.
  3. VM_BACKUP_ROTATION_COUNT=
    • Set the number of backups you'd like to keep.
  4. POWER_VM_DOWN_BEFORE_BACKUP=
    • I set this to 0 - Allows for up time = more server load.
  5. ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=
    • I set this to =1
    • This is broken as of VMFS6 ( Virtual Machine Version 11 or newer )

Add VM names to back up

Add a VM name per line and then save / close the file.

nano /home/script/MOVE-TO-ESXI/vms_to_backup

Move files to ESXI

Make the folders needed by the script. Open the datastore that you decided to use above for backups.

Make a folder called BACKUP-SCRIPT
Make a folder called BACKUP-VMS
  1. Change esxiIPaddress to the ip of your esxi server.
  2. Change DRIVEtoUSE to the drive where you'd like to store VM backups.
scp /home/script/MOVE-TO-ESXI/* [email protected]:/vmfs/volumes/DRIVEtoUSE/BACKUP-SCRIPT/

ssh into ESXI and set ghettoVCB.sh as exactable.

ssh [email protected] 
cd /vmfs/volumes/DRIVEtoUSE/BACKUP-SCRIPT/
chmod +x ghettoVCB.sh

Run a test

cd /home/script/
./runme.sh

To check if worked check your Datastore and folder name for each vm you should see STATUS.ok

NOTICE:

If you don't see Remove snapshot like below then you will need to do the below Fix.


Setup ghettoVCB.sh to auto run at midnight.

crontab -e
0 0 * * *  /home/script/runme.sh

Fixes:

Fix issues with old Snapshots not being removed

On the Debian server make a rmsnapshot.txt that holds the VM ids for VMs you want to backup.

Run the following command and copy the id # for each vm that you want to backup - matching the vms_to_backup file.

vim-cmd vmsvc/getallvms | sed -e '1d' -e 's/ \[.*$//' | awk '$1 ~ /^[0-9]+$/ {print $1":"substr($0,8,80)}'

cd /home/script/

nano rmsnapshot.txt

add a line per each vm add the id at the end.

vim-cmd vmsvc/snapshot.removeall 1
vim-cmd vmsvc/snapshot.removeall 2
vim-cmd vmsvc/snapshot.removeall 42

Add the following line to runme.sh

nano /home/script/runme.sh

sshpass -p 'esxiPW' ssh -o StrictHostKeyChecking=no [email protected] < /home/script/rmsnapshot.txt

runme.sh should look like this once done.

sshpass -p 'esxiPW' ssh -o StrictHostKeyChecking=no [email protected] < /home/script/rmsnapshot.txt
sshpass -p 'esxiPW' ssh -o StrictHostKeyChecking=no [email protected] < /home/script/backup.txt
  • Change esxiPW to the password of your ESXI server.
  • Change esxiIPaddress to the ip of your ESXI server.