A little script to clone a VM with VMware ESX/ESXi (but no VirtualCenter)

I wanted to strike this one for my own records...

I was looking for an easy way to clone a VM without VirtualCenter and came across this, which worked like a charm, bits of which I had done before for other purposes...

http://hsukumar.wordpress.com/2008/05/14/esx-clone-without-virtual-center

So I came up with a little automation, good for when you have to "create a few"... Change according to your datastore!

Script: clone-system name-of-source-vm name-of-target-vm

SOURCEVM=$1
TARGETVM=$2
DATASTORE=/vmfs/volumes/MY-VM-STORE

mkdir $DATASTORE/"$2"

vmkfstools -i $DATASTORE/"$1"/"$1".vmdk $DATASTORE/"$2"/"$2".vmdk

Comments:

Champ :-)

Worked a charm

Posted by guest on October 31, 2008 at 07:37 PM EST #

Nice Script!

I have revised it slightly for usage with multiple data stores.

SOURCEVM=$1
TARGETVM=$2
DATASTORE=/vmfs/volumes/$3
DATASTORE2=/vmfs/volumes/$4

mkdir $DATASTORE2/"$2"

vmkfstools -i $DATASTORE/"$1"/"$1".vmdk $DATASTORE2/"$2"/"$2".vmdk

Posted by Quindor on April 15, 2009 at 12:51 AM EST #

Good job Daniel. It works fine! You do not need to declare the to variables SOURCEVM and TARGETVM. If you dismiss the two first lines is going to work fine as well (a comment just to optimize your code)

;-)

Thank you!

Posted by guest on July 07, 2011 at 02:29 AM EST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

A thin thinker down under

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today