VMware Cloud Community
hama007
Contributor
Contributor

roadmap for automatic delet a virtual machine and import a new from an image

hi,

i will create a backup virtual machine for a running physical machine!

i have running a physical machine, this was saved 2 times in the week with an image software

now i will create an automatical job in vi, that was import this image in vi

before the import, the old available vm delet

how can i do this?

0 Kudos
5 Replies
haif
Enthusiast
Enthusiast

Hi,

I have had the same idea.

This is a great way to get an image level backup of a physikal maschine without any imaging or backup software.

But I have some problems to get a working solution.

I think the only way to do this is over viperl toolkit, because there is no sheduled task in vc to delete a vm.

My concept was creating a perl script which will do the following steps:

  • delet the previous vm from vc

  • create a new import task in vc under scheduled tasks

The first step is very easy.

Searching the vc inventory for the specified vm and then run the destroy_task on the vm object.

But for the second step I haven't found any code snippets in the community.

So if anybody can help here with an example?

This would be helpful.

-


Patrick Häfner

VMUG Leader Germany South

Patrick Häfner, VCP on vSphere 5, vExpert 2009 & 2010 & 2011 & 2012 & 2013 & 2014, VMUG Leader Germany South
0 Kudos
kjb007
Immortal
Immortal

VMware converter includes experimental support for a command line interface p2vtool. That may do exactly what you want to do. It is included with converter, and you will need an enterprise license for it. I haven't used it, and not sure of its capabilities, but it is an option to look into.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos
hama007
Contributor
Contributor

Hallo,

bin mit Powershell und vi-toolkit noch nicht so ganz fit!

Kannst du mir ein bespielt für das auslesen der vm´s und das löschen geben?

Danke

0 Kudos
haif
Enthusiast
Enthusiast

Hello,

the p2v-comandline is not an option. I haven't tested it. I want to do it with viperl toolkit.

Perhals somebody can help us?

The script I have added to this post will do the delete of the VM. So this is the first step like described above. The script is not perfect, but it works.

Now we need an example how we can use the viperl toolkit methode "CreateScheduledTask" to create a new scheduled import virtual machine task in the vc scheduler. My problem is that I don't know how the "ScheduledTaskSpec" for an Import virtual machine task looks like?

Sorry for my bad english.

@hama007:

das Löschen kannst du über das angehängte Script machen. Ist eventuell nicht perfekt, aber funktioniert.

Anschliessend müsste man meiner Ansicht nach nur die Methode "CreateScheduledTask" mit dem entsprechenden "ScheduledTaskSpec" aufrufen, um im VC Task Scheduler eine neue Task zu erhalten.

Bisher habe ich leider noch nirgends was gefunden, wie man diesen "ScheduledTaskSpec" für einen Import Task zusammenstellt.

-


Patrick Häfner

VMUG Leader Germany South

Patrick Häfner, VCP on vSphere 5, vExpert 2009 & 2010 & 2011 & 2012 & 2013 & 2014, VMUG Leader Germany South
0 Kudos
haif
Enthusiast
Enthusiast

Hi,

this question is solved with (I think) ESX Update 3 + VC 2.5 Update 3.

After this update you can create a sheduled task in VC to import the physical machine, shedule them to for example a weekle repeat and you can specify what to do with the previous imported vm. One option is to delete the previous vm after the import is done. So you need temporary twice storage. But this implementation works fine. So you can easily backup physical machines weakly to a vm, which you can start in a DR event.

-


Patrick Häfner

VCP on VI3, vExpert 2009

VMUG Leader Germany South

Patrick Häfner, VCP on vSphere 5, vExpert 2009 & 2010 & 2011 & 2012 & 2013 & 2014, VMUG Leader Germany South
0 Kudos