I've gone and "helped myself" to add some new functionality to the script. I wanted to share my updates in case anyone would find them useful, as well as for William to review for inclusion in the authoritative version of the code.
1) added a "doall" command-line option; this eliminates the need to create (and maintain!) a list of VMs; it simply logs into your infrastructure and creates a list of all the VMs present. It isn't coded in the most efficient way; I simply borrowed some of the existing code for object discovery. At some point I may revise it to allow you to "do all" for an optionally named cluster in the "Hosts and Clusters" vCenter view or folder in the "VMs and Templates" view (i.e., do all the VMs logically contained in the "production" folder and its subfolders), but my current need was to eliminate the need to maintain a list...
2) because I had a couple of VMs that needed special handling, I revised the operation of per-VM config files so that things behaved better in conjunction with my "do all" operation: VMs specified in the list (or discovered using the "doall" command) will backup using defaults if a config file isn't present. As an additional adaptation, I revised the configfile reader to use the script defaults unless otherwise specified in the config file; that means the config file doesn't require every single setting to be present, just the ones you want to override for custom action. I did that because I didn't want to have to maintain every config file whenever I changed a default that didn't have bearing on the actual reason a unique config was needed (in all my cases, it was whether or not storage quiescing was going to succeed: my default is to request it, but I have a handful of VMs that won't succeed for some reason).
3) added a command-line "loglevel" option to override the script's default logging level. This lets you leave the script at something like "info" for regular automation, but use "debug" when troubleshooting a single machine.
Note: I'm making these changes to suit my environment's needs; your mileage may vary. Credit and thanks goes to William for doing the majority of the "heavy lifting" on the original code. Without his work, mine wouldn't exist.
ghettoVCBg2.pl 38.7 K