화요일, 12월 10, 2024
HomeESXiVMware ESXi 가상호스트 Copy Shell Script

VMware ESXi 가상호스트 Copy Shell Script

VMware ESXi 가상호스트 Copy Shell Script

Source VM : basic-ubuntu
Source Dir : /vmfs/volumes/120G_SSD
Target VM : dns-ubuntu
Target Dir : /vmfs/volumes/240G_SSD

예) esxi-vmdk-copy.sh basic-ubuntu 120G_SSD dns-ubuntu 240_SSD

관련 스크립트

#!/bin/sh -x
if [ $# -ne 4 ];then
echo "USAGE : $0 Source_dir_Name Source_Full_Path Dest_dir_Name Dest_Full_Path"
echo "USAGE : $0 basic-ubuntu 120G_SSD dns-ubuntu 240_SSD"
exit
fi
SRC="$1"
SRC_DATASTORE="$2"
DEST="$3"
DEST_DATASTORE="$4"
if [ ! -d "$SRC_DATASTORE/$SRC" ];then
	echo "Source Dir \"$SRC_DATASTORE/$SRC\" is not exist"
exit
fi
if [ -d "$DEST_DATASTORE/$DEST" ];then
	echo "Dest Dir \"$DEST_DATASTORE/$DEST\" is aleady exist"
exit
fi
mkdir "$DEST_DATASTORE/$DEST"
vmkfstools -i "$SRC_DATASTORE/${SRC}/${SRC}".vmdk "$DEST_DATASTORE/${DEST}/${DEST}".vmdk
						
cp "$SRC_DATASTORE/${SRC}/${SRC}".vmx "$DEST_DATASTORE/${DEST}/${DEST}".vmx
cp "$SRC_DATASTORE/${SRC}/${SRC}".vmxf "$DEST_DATASTORE/${DEST}/${DEST}".vmxf
										
sed "s/${SRC}/${DEST}/g" "/vmfs/volumes/$DEST_DATASTORE/${DEST}/${DEST}".vmx
sed "s/${SRC}/${DEST}/g" "/vmfs/volumes/$DEST_DATASTORE/${DEST}/${DEST}".vmxf
										
echo "Done.!"

참조 사이트 : https://www.lesstif.com/pages/viewpage.action?pageId=12943617

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular