If you want to script registering a lot of clients using ssh from a single host you can use avagent.d instead of avregister to register without an interactive shell on the host.
/opt/AVMRclnt/etc/avagent.d
register your_utility_node_name your_domain
Over the last few years I've learned a lot from random blogs and forum hits. I figured it's time I give a little of it back. Hopefully someone finds something useful.
Thursday, April 16, 2015
Hello
I've received a lot of Avamar help from blogs and forums over the last couple years. I figured I'd drop some of the tips and tricks here to give a little back.
Scripting VM Recovery for DR or other mass restores
Our DR plan involves restoring a lot of VMware virtual machines to a new Vcetner. I wrote a script to be run on the Avamar utility node to automate it. One quirk about restoring from a replicated copy with this method is that when you replicate a VM backup to another grid it adds a tag to the end of the backup name so you can't just use a client name list. To make this script work you need to:
It does a minor amount of error checking and logs to an output file so you can see what VMs did not successfully submit a restore.
If anyone knows how to get a backup list based on a domain from CLI when there are no clients registered on that grid (just replica copies) please let me know. That would fix the whole vm_lookup_list part of this.
Feel free to use this and modify as needed. I'd appreciate any feedback if you think there is something to make it better.
#!/bin/bash
## Christian Schmidt 4/6/2015
## cgschmidt@landolakes.com
## Script to bulk restore VMs @ DR. It must resides in /home/admin/vmware_restore_script/
## folder must have vm_lookup_list containing the full avamar name of the servers (cut and paste from the restore area in the GUI)
## folder must have vmlist containing a simple list of vmnames to be restored
## ESX hosts names must be formatted as DRVMhost(count) edit the count of ESX hosts by changing ESXHOSTCOUNT variable
## Datastores must be formatted as vol(count) edit the count of datastores by changing the DSCOUNT variable
## montitor /home/admin/vmware_restore_script/vmrestore.log for success or failure of particular backups
##Domain replicated backups exist in
DOMAIN=REPLICATE/ahavmrun.ent.lolcentral.com/vmware.ent.lolcentral.com/windows-prod
##fqdn of the Vcenter
TGTVCENTER=vmware2.ent.lolcentral.com
##VMware Datacenter
TGTDC="Atlanta"
##VMware folder to put the VM in
TGTFOLDER=avamar_restores
##number of esxhosts named DRVMhost#
ESXHOSTCOUNT=3
##number of datastores named vol#
DSCOUNT=2
##setting counters
ESXCOUNTER=0
DSCOUNTER=0
echo "============================================================================" >> /home/admin/vmware_restore_script/vmrestore.log
echo "Starting VMware restore script at $(date)" >> /home/admin/vmware_restore_script/vmrestore.log
echo "============================================================================" >> /home/admin/vmware_restore_script/vmrestore.log
for SHORTSERVER in $(cat /home/admin/vmware_restore_script/vmlist)
do
if [[ $(grep -i -c $SHORTSERVER /home/admin/vmware_restore_script/vm_lookup_list) -eq 1 ]]
then
SERVER=$(grep -i $SHORTSERVER /home/admin/vmware_restore_script/vm_lookup_list)
else
echo "ERROR: failed to lookup full server name for" $SHORTSERVER >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
LABELNUM=a
LABELNUM=$(mccli backup show --domain=$DOMAIN --name=$SERVER | grep -E "CST|CDT" | awk '{print $4}' | sort -rn | head -1)
if [[ $LABELNUM -gt 0 ]]
then
let ESXCOUNTER=$ESXCOUNTER+1
let DSCOUNTER=$DSCOUNTER+1
mccli backup restore --name=$SERVER --domain=$DOMAIN --plugin=3016 --labelNum=$LABELNUM --restore-vm-to=new --virtual-center-name=$TGTVCENTER --datacenter=$TGTDC --folder=$TGTFOLDER --dest-client-name=${SHORTSERVER} --esx-host-name=DRVMhost$ESXCOUNTER --datastore-name=vol$DSCOUNTER
if [[ $? -eq 0 ]]
then
echo "SUCCESS: $SERVER Restore started" >> /home/admin/vmware_restore_script/vmrestore.log
else
echo "ERROR: $SERVER mccli restore command failed, mccli return code $?" >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
else
echo "ERROR: Unable to lookup labelnum for " $SERVER >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
if [[ $ESXCOUNTER -eq $ESXHOSTCOUNT ]]
then
ESXCOUNTER=0
fi
if [[ $DSCOUNTER -eq $DSCOUNT ]]
then
DSCOUNTER=0
fi
done
echo "========================Script completed $(date)==============================" >> /home/admin/vmware_restore_script/vmrestore.log
- Put it and the other required files in /home/admin/vmware_restore_script
- Go into the GUI and copy/paste all names of the backup names (clientname_avamartag) into a file called vmware_lookup_list
- create a file called vmlist containing all of the servers you want to restore.
It does a minor amount of error checking and logs to an output file so you can see what VMs did not successfully submit a restore.
If anyone knows how to get a backup list based on a domain from CLI when there are no clients registered on that grid (just replica copies) please let me know. That would fix the whole vm_lookup_list part of this.
Feel free to use this and modify as needed. I'd appreciate any feedback if you think there is something to make it better.
#!/bin/bash
## Christian Schmidt 4/6/2015
## cgschmidt@landolakes.com
## Script to bulk restore VMs @ DR. It must resides in /home/admin/vmware_restore_script/
## folder must have vm_lookup_list containing the full avamar name of the servers (cut and paste from the restore area in the GUI)
## folder must have vmlist containing a simple list of vmnames to be restored
## ESX hosts names must be formatted as DRVMhost(count) edit the count of ESX hosts by changing ESXHOSTCOUNT variable
## Datastores must be formatted as vol(count) edit the count of datastores by changing the DSCOUNT variable
## montitor /home/admin/vmware_restore_script/vmrestore.log for success or failure of particular backups
##Domain replicated backups exist in
DOMAIN=REPLICATE/ahavmrun.ent.lolcentral.com/vmware.ent.lolcentral.com/windows-prod
##fqdn of the Vcenter
TGTVCENTER=vmware2.ent.lolcentral.com
##VMware Datacenter
TGTDC="Atlanta"
##VMware folder to put the VM in
TGTFOLDER=avamar_restores
##number of esxhosts named DRVMhost#
ESXHOSTCOUNT=3
##number of datastores named vol#
DSCOUNT=2
##setting counters
ESXCOUNTER=0
DSCOUNTER=0
echo "============================================================================" >> /home/admin/vmware_restore_script/vmrestore.log
echo "Starting VMware restore script at $(date)" >> /home/admin/vmware_restore_script/vmrestore.log
echo "============================================================================" >> /home/admin/vmware_restore_script/vmrestore.log
for SHORTSERVER in $(cat /home/admin/vmware_restore_script/vmlist)
do
if [[ $(grep -i -c $SHORTSERVER /home/admin/vmware_restore_script/vm_lookup_list) -eq 1 ]]
then
SERVER=$(grep -i $SHORTSERVER /home/admin/vmware_restore_script/vm_lookup_list)
else
echo "ERROR: failed to lookup full server name for" $SHORTSERVER >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
LABELNUM=a
LABELNUM=$(mccli backup show --domain=$DOMAIN --name=$SERVER | grep -E "CST|CDT" | awk '{print $4}' | sort -rn | head -1)
if [[ $LABELNUM -gt 0 ]]
then
let ESXCOUNTER=$ESXCOUNTER+1
let DSCOUNTER=$DSCOUNTER+1
mccli backup restore --name=$SERVER --domain=$DOMAIN --plugin=3016 --labelNum=$LABELNUM --restore-vm-to=new --virtual-center-name=$TGTVCENTER --datacenter=$TGTDC --folder=$TGTFOLDER --dest-client-name=${SHORTSERVER} --esx-host-name=DRVMhost$ESXCOUNTER --datastore-name=vol$DSCOUNTER
if [[ $? -eq 0 ]]
then
echo "SUCCESS: $SERVER Restore started" >> /home/admin/vmware_restore_script/vmrestore.log
else
echo "ERROR: $SERVER mccli restore command failed, mccli return code $?" >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
else
echo "ERROR: Unable to lookup labelnum for " $SERVER >> /home/admin/vmware_restore_script/vmrestore.log
continue
fi
if [[ $ESXCOUNTER -eq $ESXHOSTCOUNT ]]
then
ESXCOUNTER=0
fi
if [[ $DSCOUNTER -eq $DSCOUNT ]]
then
DSCOUNTER=0
fi
done
echo "========================Script completed $(date)==============================" >> /home/admin/vmware_restore_script/vmrestore.log
Monday, April 13, 2015
Checking and setting CBT for VMware image backups
Using change block tracking greatly improves VM image backup time. To ensure Avamar is using the feature you must both check the option to use it in the dataset and ensure it is turned on in VMware.
To validate it's enabled on your VMs you can use proxycp.jar
If you would like to try and enable it on all VMs:
To validate it's enabled on your VMs you can use proxycp.jar
- java -jar proxycp.jar --cbtstatus | grep -E "VM Name|CBT"
- add the --vm VMname flag to check a single server
If you would like to try and enable it on all VMs:
- java -jar proxycp.jar --cbtstatus --enablecbt
Subscribe to:
Posts (Atom)