Is there a way to consolidate VMware snapshots automatically?
IT Knowledge Exchange user MasterJohn has to generate snapshots for a specific task once a week. He recently asked if there is a way to automatically consolidate VMware snapshots in vSphere 5. Contributors Mike Nelson and Brian Knudtson suggest two options.
VMware snapshots copy a virtual machine disk file (VMDK), preserving the disk file system and system memory to prevent losses in the event that something goes wrong. IT admins initiate VMware delete snapshot operations, which consolidate snapshots back to the parent VMDK via the vSphere Client or the vmware-cmd command-line utility. If consolidations don't occur, snapshots can rapidly eat up space on a data store.
Crash course on VMware snapshots
Basics of how snapshots work
Details on deleting snapshots
Troubleshooting when snapshots go wrong
Think you're a snapshot expert? Take the quiz!
Knudtson doubts automation is an option within the VMware vSphere 5 client. He suggests using a scheduled script or an orchestration engine (e.g. vCenter Orchestrator) to accomplish the weekly automated snapshot consolidation. Nelson agrees, pointing to the commands and methods for vCenter Orchestrator in the "VirtualMachine" object of VMware's support documentation.
Consider using VMware vSphere PowerCLI, a command-line tool for controlling VMs, networking, storage and more, Nelson advises. PowerCLI from the client could be run as an automated, scheduled task once a week for MasterJohn's task. Nelson recommends using the command $VM.ConsolidateVMDisks_Task() for consolidating snapshots.
VMware users are an active community and, as Nelson points out, can "whip up a script" in no time at all. He suggests these additional resources:
- VNoob blogs about consolidating disks and orphaned snapshots with PowerCLI; and
- Members of the PowerCLI community on VMware's website can suggest smart scripts, such as in this thread about automating snapshot deletions.
Have your own answer? Share it with MasterJohn on the IT Knowledge Exchange (ITKE).
Have a question for our experts? Post it to ITKE or email the editor directly at firstname.lastname@example.org.
Dig deeper on Scripting administrative tasks
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.