backup of VMWare using ghettoVCB.sh

You can back up VMware VM for free using ghettoVCB.sh script. Everything you need is here:

https://github.com/lamw/ghettoVCB

I was unable to download it directly to the the VMware server because wget v1.19 refused to download form https:// url.

Instead I downloaded the file to my Windows machine and used WinSCPPortable to upload the file to the server.

To extract the files do:

unzip ghettoVCB-master.zip

Go to ghettoVCB-master folder and make the scripts executable:

chmod +x ghettoVCB.sh
chmod +x ghettoVCB-restore.sh

Add a new NFS share as a datastore “backup”. This is where we are going to store the backup files.

Create some folders and configuration files. A typical way to execute the script is:

./ghettoVCB.sh -f vms_to_backup -g global_config/vm_global.conf

To schedule a cron job add the following line to /var/spool/cron/crontabs/root

0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-$(date +\%s).log

Then add the following to /etc/rc.local.d/local.sh

/bin/kill $(cat /var/run/crond.pid)
/bin/echo “0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-\$(date +\\%s).log” >> /var/spool/cron/crontabs/root
crond

In order to allow the script to send emails you need to:

Step 1 – Create a file called /etc/vmware/firewall/email.xml with contains the following:


  
    email
    
      outbound
      tcp
      dst
      25
    
    true
    false
  

Step 2 – Reload the ESXi firewall by running the following ESXCLI command:

~ # esxcli network firewall refresh

Step 3 – Confirm that your email rule has been loaded by running the following ESXCLI command:

~ # esxcli network firewall ruleset list | grep email
email                  true

Step 4 – Connect to your email server by using nc (netcat) by running the following command and specifying the IP Address/Port of your email server:

~ # nc 172.30.0.107 25
220 mail.primp-industries.com ESMTP Postfix

To perform a dry run restore do:

./ghettoVCB-restore.sh -c vms_to_restore -d 1

To perform a real restore do:

./ghettoVCB-restore.sh -c vms_to_restore

Leave a Reply