• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3305
  • Last Modified:

How to Schedule VM Snapshot creation and overwrite

I have some windows servers that I need to create one snapshot every day, I need to the snapshot to overwrite the existing snapshot instead of creating new one.
I want this operation to be scheduled Monday Through Friday.

How can I do that ?

I will appreciate your help.

Thanks you
0
jskfan
Asked:
jskfan
  • 10
  • 6
  • 4
2 Solutions
 
yo_beeDirector of ITCommented:
Is this for a backup solution, if so this is not the proper method to do so. You should use a backup solution that is VM aware like VEEAM, Symantec or something similar.

Each snapshot will slow down your VM.
You should only us Snapshots when testing something and you want to role back if all hits the fan.
If the update applied after the snapshot is successful you should delete it and allow for the Snapshot to merge.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1015180
0
 
yo_beeDirector of ITCommented:
0
 
jskfanAuthor Commented:
I have some windows machines that I deploy MS Updates to, sometimes undesirable MS Updates get deployed. I believe with a Snapshot, I can revert back to the previous state of the computer.
0
Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
You will have to delete the existing snapshot, and create a new snapshot.

Get-VM | New-Snapshot -Name ”Target-Snapshot”

 or

New-Snapshot –Name “Target-Snapshot” –VM myVM

Revert to Snapshot

$snapshot = Get-Snapshot –VM myVM –Name ”Target-Snapshot”
Set-VM –VM myVM –Snapshot $snapshot
0
 
jskfanAuthor Commented:
how do u save the commands above to a script file, the put it in windows scheduled task
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
I would recommend using the following, also VMware recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI

http://powergui.org/index.jspa

and

VMware Community Pack

http://www.virtu-al.net/featured-scripts/vmware-powerpack/
0
 
jskfanAuthor Commented:
Thanks ...for now all I need is a scheduled task that takes a snapshot of the VM machine, if there is an existing snapshot I would like it to be overwritten.
The commands below you posted, might do the work as you stated, but how to make them run automatic in a scheduled task, and whether they overwrite the existing snapshot ?


<<Get-VM | New-Snapshot -Name ”Target-Snapshot”

 or

New-Snapshot –Name “Target-Snapshot” –VM myVM

Revert to Snapshot

$snapshot = Get-Snapshot –VM myVM –Name ”Target-Snapshot”
Set-VM –VM myVM –Snapshot $snapshot >>
0
 
yo_beeDirector of ITCommented:
So if you snapshot with a schedule Powershell cmdlet and you set it up to overwrite you will be breaking the links (GUID) that point to the snapshot causing undesired results.
You are dealing with many variables.
I would really rethink how you deal with updates.  
What about manually dealing with updates?
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
you cannot overwrite a snapshot.

You can only create a snapshot, delete a snapshot, or revert to a snapshot, you cannot overwrite a snapshot.

so you would need to

1. create 1st snapshot
2. create 2nd snapshot
3. delete 1st snapshot

you must delete the snapshot, and create a new snapshot using the downloads Ive suggested, you cannot use the commands unless you download and install the tools. Once you have the above tools, PowerCLI and PowerGUI to create and saved the scripts.

How you scehdule them is included in this article

http://www.virtu-al.net/2009/07/10/running-a-powercli-scheduled-task/
0
 
jskfanAuthor Commented:
I can do that manually for now, so I need:

1-Create a snapshot of VM before Deploying MS Updates.
2- Deploy MS Updates...
3- if something goes wrong after Deploying MS Updates, then Revert back to initial state


4-if everything goes fine and want to  keep the machine to the current state and get rid of the snapshot or snapshots, what should I do, seein that if I delete a snapshot if will merge with the original VM state.
0
 
jskfanAuthor Commented:
if everything goes fine and want to  keep the machine to the  state after MS Updates and get rid of the snapshot or snapshots, what should I do??
 Considering that if I delete a snapshot it will merge with the original VM state.
0
 
jskfanAuthor Commented:
if I delete a snapshot it will merge with the original VM state. which means the MS Updates will go away...which I don't want since everything went fine
0
 
yo_beeDirector of ITCommented:
If you delete the snapshot you should be fine with the update.
The Snapshot is a point in time and then a new vDisk is created with the changes.
This means that you are reading from 2 vDisks for that one OS.
When you delete the snapshot the data bits from the point after the snapshot is merged with the bits of the point prior to the snapshot to give you the up-to-date OS with the Updates that you applied.

Now if you are planning to use this method to address Updates I do not recommend you schedule auto-download and install of the Updates.  
How many servers are you dealing with? I still think you should manually deal with snapshots and updates.
You can create a batch script that will run against all your VM's and create a snapshot upon request, but I would not schedule this.
Also I would only deal with updates on a monthly basis.
0
 
jskfanAuthor Commented:
I can do snapshots manually.

Let me see if I understand the Snapshots.
example, I have VM1
Scenario 1- the MS Updates are good and need to keep them
-VM1
-Snapshot 09/12/2012
-MS Updates 09/13/2012
-in this case if I delete Snapshot 09/12/2012 , MS Updates will still be in the VM1. Correct ?
if So, I thought the MS Updates get written to the Snapshot, if I delete a Snapshot , how do the MS Updates get written to the VM1 ?



Scenario 2- the MS Updates are not good and need to get rid of them
- VM1
-Snapshot 09/12/2012
-MS Updates 09/13/2012
-in this case, I just need to revert to VM1, and the MS Updates will not be applied. Correct ?
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
VM1
If you Delete Snapshot 09/12/2012 it will be deleted, this is the Snapshot without the updates, the rollback snapshot.
MS-Updates 09/13/2012 - this is the current VM, running on this Snapshot, if you delete this snapshot, the snapshot will stop, and be merged into the parent.

VM2
Revert to Snapshot 09/12/2012 (the rollback snapshot)
Then Delete MS Updates 09/13/2012 (current snapshot with updates)
0
 
jskfanAuthor Commented:
I guess You mean , after deploying the MSupdates I need to take a snapshot
MS-Updates 09/13/2012 in addition to the existing one: -Snapshot 09/12/2012

Because on my statement I did not mean to take a snapshot afterthe MS Updates.

I meant
-Take a Snapshot 09/12/2012 of the VM1
- Deploy MS Updates 09/13/2012 to VM1
-Then if everything runs  good then delete the Snapshot 09/12/2012.
Now what I don't still understand is when Deleting the Snapshot 09/12/2012, the MS Updates will be gone away ? because I believe they get written to the snapshot first and when you delete the snapshot the data in the snapshot merges with  the data in the VM1.

=========
Sometimes when we have several snapshots but we need to revert back to the initial state of VM , and we want to get rid of the snapshots, how can we do it ? Considering deleting snapshots always makes their data commited to the VM .
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Revert to Snapshot and Delete the snapshot. (this then discards the snapshot, not merges it!)
0
 
jskfanAuthor Commented:
Let me see if Igot it:

 - VM1
- Take a Snapshot 09/12/2012 of the VM1
 Deploy MS Updates 09/13/2012 to VM1
**If Idelete Snapshot 09/12/2012 of the VM1
the MS Updates 09/13/2012 will still be commited to VM1.
Correct ?

=================================
- VM1
- Take a Snapshot 09/12/2012 of the VM1
 Deploy MS Updates 09/13/2012 to VM1
- Take a Snapshot 09/14/2012 of the VM1
 Deploy MS Updates 09/15/2012 to VM1

Now if I revert back to :Snapshot 09/12/2012 of the VM1
Would this deleted all Snapshots including Snapshot 09/12/2012 of the VM1,
and will NOT   Deploy MS Updates 09/13/2012 to VM1 Nor Deploy MS Updates 09/15/2012 to VM1.

Correct ?

Sorry I am not testing it in practice, this is why it takes time to theoritically understand it.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
- VM1
- Take a Snapshot 09/12/2012 of the VM1
 Deploy MS Updates 09/13/2012 to VM1
**If Idelete Snapshot 09/12/2012 of the VM1
the MS Updates 09/13/2012 will still be commited to VM1.
Correct ?

Correct - Yes

- VM1
- Take a Snapshot 09/12/2012 of the VM1
 Deploy MS Updates 09/13/2012 to VM1
- Take a Snapshot 09/14/2012 of the VM1
 Deploy MS Updates 09/15/2012 to VM1

Now if I revert back to :Snapshot 09/12/2012 of the VM1
Would this deleted all Snapshots including Snapshot 09/12/2012 of the VM1,
and will NOT   Deploy MS Updates 09/13/2012 to VM1 Nor Deploy MS Updates 09/15/2012 to VM1.

Correct ?

Yes and No, it does not delete the snapshots, read on, but it will not deploy the updates.

The current state of the Virtual Machine will be lost unless because it has not been saved in a snapshot, (e.g. no snapshot for 09/15/12) and you will be Reverted to Snapshot 09/12/2012 of the VM.

e.g. whatever the configuration was on the 09/12/2012. This VM configuration WILL NOT have Microsoft Updates from 09/13/2012 or 09/15/2012.

Now here is the interesting bit you mentioned Deleted snapshots, Revert DOES NOT delete Snapshots.

September Snapshots
What happens is the Revert pointer changes, you can see this by the "You are here" bubble.

To DISCARD the snapshots, you do not want to keep, you select and DELETE them, or delete buy name in the script. This does not merge them with the existing snapshot your are currently on. e.g. so your updates will not be applied.
0
 
jskfanAuthor Commented:
Thank you for efforts,..Clear explanation
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

  • 10
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now