Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #########################################################################
- #
- # save-esxi-config.sh
- #
- # Generates and downloads the configuration of a given ESXi host
- #
- # Requires SSH support on the ESXi host
- #
- # The ESXi hostname must be resolvable; may work with IP addresses but
- # has not been tested with them.
- #
- #########################################################################
- # Name of ESXi host - edit to suit your system, or make into a command-line parameter
- VM_HOST="felix.ncs"
- # Directory where we download the configuration file, edit as needed
- VM_DEST_DIR="/root/work"
- # Generate the ESXi configuration file and extract the URL we will use to download it from
- # the host. Note that we have to replace the '*' in the URL with the hostname
- echo "Generating configuration file on ESXi host $VM_HOST"
- VM_CONFIG_URL=$(ssh root@${VM_HOST} vim-cmd hostsvc/firmware/backup_config | awk '{print $7}' | sed -e "s/*/${VM_HOST}/")
- # Form target filename
- VM_DATE=$(date +%Y%m%d%H%M%S)
- VM_CONFIG_FILE="$VM_DEST_DIR"/"$VM_HOST"-configBundle-"$VM_DATE".tgz
- echo "Downloading $VM_CONFIG_URL to $VM_CONFIG_FILE"
- wget --no-check-certificate --output-document=${VM_CONFIG_FILE} ${VM_CONFIG_URL}
Add Comment
Please, Sign In to add comment