How Snapshots, Clones and Templates Can Make Your Job Easier
VMware's vSphere solutions are packed with useful tools and technologies to help IT admins get things done. VMware is renowned for their virtualization technologies that help significantly with day-to-day management activities.
When it comes to virtual machine management, it's never been easier to make recovery points, and copies of servers. In this post, we explore these technologies, including common use-cases and some of the fundamental building blocks.
How VMware Snapshots Work
VMware snapshots are recovery points of virtual machine disks. When you create a snapshot on a virtual machine, a new placeholder disk is created behind the scenes to redirect changes made to the original disk since the snapshot was taken.
This means that if you ever need to "rewind" the virtual machine back to the time you created the snapshot, you can do this in just a couple of clicks. Under the hood, the changes on the placeholder disk are discarded. Snapshots should not be left on a virtual machine for too long, this is because the placeholder disks grow in size and can eventually fill up your datastores.
Deleting a snapshot will remove the ability to recover the virtual machine to the time the snapshot was taken, it will also merge all changes made on the placeholder disk, with the original virtual machine disk. If snapshots are large, then they can take some time to merge. The great thing about snapshots is that they can be created in seconds and reverted to in seconds too. This makes them incredibly functional for busy VMware administrators.
What Does a VMware Snapshot Contain?
When you take a snapshot of a virtual machine, the power status, virtual hardware and data are saved as part of the snapshot. If you revert to a previously created snapshot, the virtual machine will be put back exactly as it was at the snapshot creation time. This includes all virtual machine hardware like disks, memory, and CPU network cards, as well as the power status (powered on, off, or suspended) if selected.
When to Use VMware Snapshots
Most commonly, IT admins will create snapshots on virtual machines before making major changes to applications or the operating systems within the virtual machine. If something goes wrong with an application, configuration change or during operating system patching, the virtual machine can be reverted to exactly how it was before commencing with the work.
You'll also find that many virtual machine backup solutions need to take a snapshot of virtual machines before they get backed up. This is to unlock the underlying virtual disks so that the backup software can copy them.
VMware Snapshots are Feature-rich
There are various configuration options available when creating snapshots. When creating snapshots, you can choose to save the memory of the virtual machine. This means that if you revert to this snapshot at a later time, the virtual machine will be restored to how it was and powered on in the same state as it was when the snapshot was taken.
In contrast, you can also take snapshots without memory. Because the memory does not need to be saved to disk, this is a much faster option. When you revert to this type of snapshot, the virtual machine will be in a powered-off state and needs to be manually powered back on afterwards. Keep in mind though, that when starting the virtual machine, it will appear as though it was forcefully powered off.
The final option is to decide if you wish to enable guest quiescing. Quiescing the virtual machine will flush in-memory caches to the disk before the snapshot is taken. This is often used by backup operations to ensure a consistent backup is taken and no memory caches are lost when restoring.
VMware Snapshots are not Backups
The most common misconception is that snapshots are backups. While snapshots allow you to revert a machine to a point in history, they are not a complete backup solution. Snapshots are simply point-in-time recovery points. The underlying files are not copies or clones in any way.
If you accidentally delete one of the files that make up a virtual machine, even with snapshots enabled, you will not be able to recover the virtual machine. For this reason, you must also deploy a suitable backup solution for your virtual machines. In summary, virtual machine snapshots compliment backups but they are not the same thing.
What are Virtual Machine Clones?
Providing that you have a vCenter server, you can take clones of virtual machines. Virtual machine clones are "almost" identical copies of a source virtual machine. By almost, we mean that the virtual machine data is an identical copy in a cloned virtual machine but certain identification markers such as the virtual machine MAC address and VM ID will be changed to keep them unique.
When Can You Clone a Virtual Machine?
You can clone a virtual machine as long as there are no conflicting tasks on the source virtual machine. If there is a snapshot consolidation process underway then you'll need to wait for this to finish before you can start the cloning process.
Because a virtual machine clone is a copy of the virtual machine's configuration and data, you need to ensure that there is enough free space on the same or other destination datastore. The process will fail if there is not enough readily available free space.
When creating the clone, you'll also be asked to specify a DRS enabled cluster or specific vSphere host. If you are not using DRS, then you must also ensure there is enough CPU and memory on the destination host to power on the virtual machine after the cloning process is complete.
VMware vSphere Clones are Highly Configurable
When running through the simple VMware vSphere clone wizard, you have the option to change some of the characteristics of the virtual machine hardware. This enables you to clone a virtual machine but alter virtual hardware such as the number of NICs or the amount of CPU and Memory for the new virtual machine.
One of the most powerful features of VMware clones is the ability to customize the virtual machine's operating system. Providing that the prerequisites are met, you can set a hostname or even change the IP address of the cloned virtual machine. All of this is possible during the cloning process without having to log in to the virtual machine at all!
Virtual Machine Templates are Key to Automated VM Deployment
If you are frequently deploying new virtual machines, you might want to consider building a virtual machine template.
Once you have installed your operating system and base applications onto a virtual machine, you can proceed to convert this virtual machine into a template.This process can be completed in a matter of seconds. The real magic with templates comes when you build a new VM from a template and attach a customization specification.
A customization specification allows you to customize the virtual machine hostname, timezone, network details and DNS configuration details within the operating system. You can use customization specifications with both templates and clones.
Automating Virtual Machines with PowerCLI
If you have a considerable number of virtual machines to create, you can combine the power of virtual machine templates and customization specifications with PowerCLI. This means that with a single command you can create many virtual machines from your template and fully customize them by specifying a customization specification.
Advantages of Virtual Machine Templates
Virtual machine templates unlock the ability to quickly deploy many virtual machines, so there are several advantages made available to VMware admins:
Eliminate Human Error. Building a new virtual machine from scratch is a simple enough task but to do this many times manually, makes room for human error. Templates and clones prevent misconfiguration of virtual machines, eliminating human error.
Significant Time Savings. Because the virtual machine creation process can be fully automated, VMware admin time is reduced from hours or days down to just a few seconds to commence the virtual machine deployment process.
Standard Server Builds. Many businesses suffer from having to manage dozens or hundreds of virtual machines, each configured differently. This can be an administrative nightmare. Adopting VMware templates can help eliminate the challenges associated with these issues.
VMware snapshots, clones, and templates are incredibly useful technologies, which in true VMware style, are very easy to use. Snapshots allow us to roll back a virtual machine state to a point in the past, whereas full clones can be used to take a complete copy of a virtual machine. Templates extend on the cloning technology since you can clone a virtual machine to a template, then deploy hundreds of virtual machines rapidly and automatically configure them with a customization specification.
All three solutions can be completed via the vSphere Web Client user interface, or programmatically with just a few lines of PowerCLI code. Many 3rd party solutions can further expand on the benefits discussed today. Our lives as VMware administrators are busier than ever, so making use of these technologies are critical to getting more done with less time, while at the same time reducing business risk and improving standardization.