ESXI Клонировать виртуальную машину из CLI

#!/bin/sh

WORK_DIR=/vmfs/volumes

SRC_VM_NAME=kubespray01
DST_VM_NAME=kubespray0002

SRC_DIR_NAME=datastore1
DST_DIR_NAME=test1

mkdir -p ${WORK_DIR}/${DST_DIR_NAME}/${DST_VM_NAME}

vmkfstools --clonevirtualdisk ${WORK_DIR}/${SRC_DIR_NAME}/${SRC_VM_NAME}/${SRC_VM_NAME}.vmdk ${WORK_DIR}/${DST_DIR_NAME}/${DST_VM_NAME}/${DST_VM_NAME}.vmdk --

grep -vE '^(sched.swap.derivedName|uuid.location|uuid.bios|ethernet0.generatedAddress|extendedConfigFile|vc.uuid|scsi0.sasWWID|vmci0.id) = ' \
${WORK_DIR}/${SRC_DIR_NAME}/${SRC_VM_NAME}/${SRC_VM_NAME}.vmx > ${WORK_DIR}/${DST_DIR_NAME}/${DST_VM_NAME}/${DST_VM_NAME}.vmx

sed -i "s|${SRC_VM_NAME}|${DST_VM_NAME}|g" ${WORK_DIR}/${DST_DIR_NAME}/${DST_VM_NAME}/${DST_VM_NAME}.vmx

cp ${WORK_DIR}/${SRC_DIR_NAME}/${SRC_VM_NAME}/${SRC_VM_NAME}.nvram ${WORK_DIR}/${DST_DIR_NAME}/${DST_VM_NAME}/${DST_VM_NAME}.nvram