ESXi

 View Only
  • 1.  Snapshot Create and Revert

    Posted Jul 02, 2012 02:29 PM

    Hey guys,

    Has anyone ever came accross a good script to do this? I am running ESXI 5.0(Free) and have a VM that I use as a lab enviroment. I am trying to see if a script can be done that will allow a VM to snapshot itself during certain times than revert the snapshot back to the "Gold" copy during a certain day - I also make sure I have a clean copy of the OS before I start breaking it.

    I assume I can write something in Power CLI but wasnt sure if a script can be written to accomplish this before I started to dig into it more.

    Thank you guys for your help!



  • 2.  RE: Snapshot Create and Revert
    Best Answer

    Posted Jul 02, 2012 02:44 PM

    using these can work from withing esxi itself.

    vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] [snapshotDescription] [includeMemory] [quiesced]

    vim-cmd vmsvc/snapshot.create [VmId] [snapshotName] are needed

    vim-cmd  vmsvc/snapshot.revert [VmId] [snapshotLevel] [snapshotIndex]

    vim-cmd vmsvc/snapshot.removeall  [VmId]

    to get your VMID do  vim-cmd vmsvc/getallvms

    This might help you understand vimID a bit more, http://sparrowangelstechnology.blogspot.com/2012/06/power-off-virtual-machines-via-command.html

    but there is a lot out there.



  • 3.  RE: Snapshot Create and Revert

    Posted Jul 02, 2012 02:50 PM

    Thanks for the fast reply!

    Does the above method allow me to set a schedule task to automaticly run those commands? I know with ESX you have more access to the linux os to run commands but since ESXI is more restricted I am not sure if it allows schedule tasks to run on the local box or if I need to iniate it elsewhere to get the timing correct.

    Thank you again!



  • 4.  RE: Snapshot Create and Revert

    Posted Jul 02, 2012 04:31 PM

    This page might help you more

    http://dcinfrastructure.blogspot.com/2011/01/create-and-delete-snapshots-on-schedule.html

    it uses powershell, and you can sceduale it via windows scedualed tasks.

    it would be preferable if you have multiple hosts/ vsphere itself better for growth.

    vim-cmd would only work with one host.



  • 5.  RE: Snapshot Create and Revert

    Posted Jul 03, 2012 04:44 PM

    Thank you for the responces. I ended up using your first suggestion and used a script to ssh into my esxi box and run the commands.