How to retire unavailable (grayed out) Avamar VM after being deleted or recreated as unavailable in vCenter resync via CLI

When adding VMs from vCenter to Avamar, a new client entry in the UI corresponding to the VM added is seen. When VM is deleted or re-created in source vCenter, after VM resync from Avamar, this VM appears as unavailable.

If VM is added again to Avamar, it creates an entry because VM ID from vCenter has changed. For Avamar, this is a new client and an old VM client instance is still seen. We have to RETIRE these entries as they are not in active configuration. By default, only the RETIRE option is available from the UI or CLI but one VM at a time. This script identifies and retires those VMs automatically.
 

AIM of this tool

This tool lets us generate a list of “Deleted VM” in order to RETIRE them from Avamar configuration. This tool is not an official tool, use it with care, and at your own risk.

We have two ways of using the tool:
Option l (List): Can create a stand-alone file with RETIRE commands to do it manually.
Option r (Retire): Can generate a file and do retiring process of all Deleted VMs automatically.

Tool can be added to Avamar CRONTAB in order to automate execution.

Tool Usage

Download the tool that is attached to this KB. This is a ZIP file, you must extract it to get access to BASH script. Put the tool on Avamar /home/admin folder for example. 

################################################################################
Syntax: Retire_Greyed_VM [-h|l|r|V]
options:
h     Print this Help.
l     Generate RETIRE greyed VMs command file ONLY 
r     Generate RETIRE greyed VMs command file AND execute RETIRING process
V     Print software version and exit.

################################################################################
Crontab launch
################################################################################
To launch script automatically add these lines in admin crontab
log as root then crontab -u admin -e
add these lines at end of crontab
#Retire Greyed VM in Avamar every Mondays at 10am
00 10 * * 1 /bin/bash /home/admin/Retire_Greyed_VM.sh -l > /tmp/Retire_Greyed_VM-`date "+\%Y-\%m-\%d"`.log 2>&1
################################################################################

Run the tool:
Create Deleted VM listing:

/home/admin/Retire_Greyed_VM.sh -l

A file is created in /tmp/Retire_Greyed_VM_RetireVMList.sh.
Create Deleted VM listing and Perform Retiring process

/home/admin/Retire_Greyed_VM.sh -r

A file is created in /tmp/Retire_Greyed_VM_RetireVMList.sh.
Retiring process is done automatically on listed VMs.
Note: 
If an error appears during script execution like “Retire_Greyed_VM.sh: line 5: syntax error near unexpected token `$’\r””, this is because of invisible Windows characters in the script that Linux does not know how to interpret. Convert it as Linux character and that should be OK.

Leave a Reply

Your email address will not be published. Required fields are marked *