This script is written by me and contributed for all to use and improve or tell me someone already did it
It's little shell script for one-step cloning of VM's in VMWare Server running under Linux. So far it works for me*. I think it accounts for everything necessary to copy a VM to another name and it will not allow you to overwrite an existing VM. It copies the directory from the source to the destination, then renames all the files with the old VM name to the new one, then uses sed to replace occurrences of the old name with the new one in all the text config files.
After running, you can just add the new VM to the console, make sure you choose "I copied it" when asked so it will fix all the little things that need to be unique. The VM should work from there.
Save the attachment to your "Virtual Machines" directory (default =is '/var/lib/vmware/Virtual Machines') and make it executable (chmod +x <filename>). Run it like this as root or sudo:
./clone_vm.sh <source vm> <new vm>
Example - to copy a vm called "WindowsXP_Template" to a new machine called WinXP:
./clone_vm.sh WindowsXP_Template WinXP
or use quotation marks around names with spaces:
./clone_vm.sh "Windows XP Template" "My New XP VM"
I went to great lengths and many, many four letter words to make this work with spaces in the file names.
If you use tabs to complete the names when you type, make sure you get rid of the "/" character at the end of the name.
*Caveats: I have not tried this on any VM's with a snapshot yet - I don't know what will happen or if I left anything out that needs to be handled. The script is written to require the VM to be shut down first, if there are .lck's it will quit and yell at you. If you use tabs to complete the directory names when you type, make sure you get rid of the "/" character at the end of the name and don't use the escape character format with spaces (like Windows\ XP\ VM) use quoting (like "Windows XP VM"). Actually I haven't tested that so it MIGHT work, but no promises.
This is my first shell script so there might be a better way to do it, anyone feel free to suggest if you know a better way to do anything in it.
clone_vm.sh 1.1 K