A VMware snapshot captures the entire state of a virtual machine at a specific point in time. This includes:
- Virtual machine files such as vmdk files
- Memory state
- Settings and configuration
- Applications and data inside the VM
Snapshots enable you to restore a VM to the exact state when you took the snapshot. They provide an easy way to rollback changes made to a VM.
For example, before applying a major update to an application or OS inside a VM, you can take a snapshot. If the update causes problems, simply revert to the snapshot to undo all changes made after that point.
How VMware snapshots work
VMware snapshots utilize redo logging to maximize performance and efficiency. Here is an overview of the technology:
- When a snapshot is taken, a delta file is created to log all subsequent changes to the virtual disk. This avoids altering the base VMDK file.
- Memory state is also saved to a snapshot file when created.
- Further writes to disk or memory divert to the delta file, preserving the base VMDk as it was at the moment of snapshot.
- If reverting to a snapshot, the changes logged in the delta file are simply discarded. The base VMDK and memory state from the snapshot restore the VM to that exact point-in-time.
This approach enables snapshots to be extremely fast with minimal performance impact. It also offers rapid restore times.
Key benefits of VMware snapshots
VMware snapshots provide a number of advantages:
- Quick rollback of changes: With snapshots, you can swiftly undo extensive changes made to a VM by reverting to an earlier point-in-time. Far faster than full VM restoration.
- Test environments: Test risky tasks like OS patches, driver updates, or application installs safely using snapshots. Discard snapshots rather than changes if issues emerge.
- Backup protection: While not a backup replacement, snapshots provide an extra layer of protection against unwanted changes between backups.
- Changelog tracking: Use snapshot names and descriptions to annotate VM changes for audits and reviews.
How to take a VMware snapshot
Taking a snapshot is a simple and fast process completed in the vSphere client:
- Right-click on the target VM in the vCenter inventory and select Snapshot > Take Snapshot.
- Enter a unique name and description for the snapshot.
- Click OK to take the snapshot.
A snapshot now captures the current state of that VM. An icon appears under the VM marking the existence of snapshots.
VM snapshot limits
By default, vSphere allows a maximum of 32 snapshots per VM. However, this can be increased to 256 by editing the VM settings.
Try to minimize snapshots where possible for ideal performance. Delete old snapshots which are no longer needed.
Can you take a snapshot of a snapshot?
Yes, you can take snapshots of existing snapshots using the same method. This creates a snapshot tree.
Reverting to the most recent snapshot in the tree eliminates all subsequent snapshots. You can still revert individually to any previous snapshot and retain newer ones if required.
When to take a VMware snapshot
Common use cases for VM snapshots include:
- Before major OS or application updates
- Before VM configuration changes like adding vCPUs or memory
- Before extensive VM troubleshooting
- Before risky tasks like repairs, migrations or splits
- Before patching or upgrades to virtualization infrastructure
- Before and after VM backups to enable quick restores
- After reaching project milestones or other logical save points
Refrain from using snapshots extensively or long-term due to potential performance impacts. Keep only required snapshots for as long as needed.
How to revert to a VM snapshot
If changes made since a snapshot cause problems, reverting replaces the current VM state with the snapshot:
- In the vSphere client inventory, right-click the VM and select Snapshots > Snapshot Manager.
- In the tree, select the desired snapshot.
- Click the Go to snapshot button.
- Confirm the revert to initiate rollback to that point-in-time.
The VM will power off and restore disk/memory states from the snapshot. It can then be powered back on with configuration matching exactly when you took that snapshot.
How to delete a VMware snapshot
Deleting unneeded snapshots saves storage space and improves performance. You can remove snapshots individually or consolidate to merge change data:
- Open Snapshot Manager for the VM as above.
- Right-click any unneeded snapshot and select Delete.
- Confirm deletion in the prompt.
- In Snapshot Manager, right-click the base snapshot you wish to consolidate down to.
- Select Consolidate.
- Check any newer snapshots you wish to merge and click OK.
- This merges all changes in newer snapshots and retains the selected base snapshot.
- Avoid deleting older snapshots that newer snapshots depend on. Use consolidate instead.
- Consolidating retains VM changes in a single snapshot chain rather than multiple branches.
- Deleting the base current snapshot effectively discards all VM changes since creation.
VM snapshot tips
Follow these tips for best practices when working with VM snapshots:
- Test applications and infrastructure changes using snapshots before deploying to production VMs.
- Set naming conventions like date or change details so snapshots are easily identifiable.
- Limit snapshot retention time to minimize size/performance impact, ideally less than 24 hours.
- Consolidate snapshot branches frequently to prevent tree depth building excessively over time.
- Delete unneeded snapshots routinely rather than letting them accumulate.
- Consider scheduled or automated scripts to check and consolidates snapshot trees.
- Always test reverting snapshots on clone or backup VMs prior to using for disaster recovery on critical VMs.
- VMware snapshots save the full state of a VM to enable rollback to that point-in-time.
- Minimal performance impact via use of delta disk files and memory logging.
- Enable safe testing, easy rollback and changelog tracking.
- Create, manage and automate snapshots through the vSphere client.
- Consolidate branches and limit depth for optimal performance.
VMware snapshots provide powerful, efficient protection and testing capabilities for virtual infrastructure. When leveraged properly, they enable IT teams to innovate fearlessly while safeguarding production environments. Mastering best practices for creating, managing and consolidating VMware snapshots is critical for maximizing this value.
Frequently Asked Questions
- What are the key benefits of VMware snapshots?
The main benefits are quick rollback of unwanted changes, testing changes safely with easy revert, added protection between backups, tracking VM changelog, and enabling faster restore options.
- Do snapshots impact VM performance?
Minimal impact occurs due to the disk delta file and redo logging approach. However, excessive snapshots or deep chains will degrade performance over time.
- Are snapshots an alternative to VM backups?No, snapshots provide point-in-time recovery but do not replace comprehensive backup solutions and disaster recovery systems.
- Can you take a snapshot while a VM is powered on?
Yes, snapshots capture the live state of a running VM without needing to power down first.
- Do snapshots take up storage capacity?
The delta files consume space according to how much data changes after taking the snapshot. Consolidating merges this data to minimize capacity.
- What is the maximum number of snapshots per VM?
The default per-VM snapshot limit is 32 but this can be increased to 256 if needed.
- How long should you keep a snapshot?
Balance recovery needs against performance impact. Ideally retain snapshots less than 24 hours then consolidate or delete.
- Can you revert a snapshot if a VM was migrated between hosts?
Yes, VMware snapshots work independently of underlying infrastructure.
- What happens if the VM snapshot files become corrupted?
This risk is minimized due to those files not being in active use while snapshots exist. But consolidation and fresh snapshots is recommended if corruption occurs.
- Can you automate snapshot scheduling?
Yes, PowerCLI enables full automation for snapshots. You can script creation, consolidation and deletion based on schedules or events.
- If hardware fails, can I recover a VM from snapshot?
Snapshots restore software state only. The VM configuration and hardware environment must be replicated to enable a true failover.
- How can I test an OS update using snapshots?
Take a snapshot, apply the update to the test VM, test thoroughly, then either revert snapshot or consolidate to commit the change.
- Is an ISO VM template considered a snapshot?
No, templates are master copies rather than snapshots. Use templates for standing up new VMs then snapshot those instances.
- Will host maintenance pause any currently active VM snapshots?
No, existing snapshots remain unaffected by routine host maintenance. Only VM migrations will pause snapshot processes until completed.
- Can I use Storage vMotion for snapshot VMDKs?
Generally it’s better to use standard vMotion between compatible datastores. Storage vMotion locks VMDKs so snapshots could be disrupted during migration.
- Does deleting a snapshot impact VM resource allocation?
No, computing resource limits like vCPU, memory, etc remain unchanged when deleting snapshots from a VM.
- How can I monitor infrastructure demand from snapshots?
Resource consumption data like IOPS and capacity is available per-VM within vCenter to track infrastructure impact.
- Is floppy media accessible if I boot a VM from a snapshot?
No, floppy media is not retained when reverting to a snapshot. Floppy data should be migrated elsewhere before relying on a snapshot for recovery.