#!/bin/bash # # Author: Clyde Goffe # Date: 12/15/07 # # Script to clone an existing VM. This script will create all directories # for you. The script assumes your base VM's directory name is the same as # your base VM. The script also assumes the display name of the base VM is the same as the base VM. Supply the name of the base VM as first argument and # the name of the clone as second. # # The script is only intended for cloning a base VM with a freshly installed OS # and no snapshots. # Base VM should be powered down. # Run script one level up from your base VM files. # Example: clone-vmware baseVM cloneVM # # baseVM=`ls *.vmx | awk -F"." '{print $1}'` baseVM=$1 cloneVM=$2 cp -ax $baseVM $cloneVM cd $cloneVM vmware-vdiskmanager -n $baseVM.vmdk $cloneVM.vmdk sed -i s/$baseVM.vmdk/$cloneVM.vmdk/ `ls` sed -i s/"$baseVM"/"$cloneVM"/ $baseVM.vmx mv $baseVM.vmx $cloneVM.vmx mv $baseVM.vmsd $cloneVM.vmsd cd ..