선 밖에 선 자유인

VMware ESXi 간단한 VM Copy script 본문

IT/System & Network

VMware ESXi 간단한 VM Copy script

Hotman 2020. 2. 13. 14:56

#!/bin/sh

echo -e "OLD : \c"
read OLD

echo -e "NEW : \c"
read NEW

mkdir /vmfs/volumes/datastore1/${NEW}
vmkfstools -i "/vmfs/volumes/datastore1/${OLD}/${OLD}.vmdk" "/vmfs/volumes/datastore1/${NEW}/${NEW}.vmdk"
cp /vmfs/volumes/datastore1/${OLD}/${OLD}.vmx /vmfs/volumes/datastore1/${NEW}/${NEW}.vmx
cp /vmfs/volumes/datastore1/${OLD}/${OLD}.vmxf /vmfs/volumes/datastore1/${NEW}/${NEW}.vmxf
cp /vmfs/volumes/datastore1/${OLD}/${OLD}.vmsd /vmfs/volumes/datastore1/${NEW}/${NEW}.vmsd
sed -i "s/${OLD}/${NEW}/g" /vmfs/volumes/datastore1/${NEW}/${NEW}.vmx

vim-cmd solo/registervm /vmfs/volumes/datastore1/${NEW}/${NEW}.vmx

VMID=`vim-cmd vmsvc/getallvms | grep "${NEW}" | awk '{print $1}'`

Comments