VM snapshots and backups
Virtual machine (VM) provides a secure sandbox environment for testing programs or accessing virus-infected data, the ability of not affecting physical machines has made it popular with businesses.
When using VMs, protecting data is one of the most important tasks. Virtual machine backups and snapshots are both common measures to ensure data security.
But what is the difference between a snapshot and a backup, and how to use them properly? Many users have been troubled by this question. This article is mean to answer it.
What is Virtual Machine snapshot (VM snapshot)
A VM snapshot is an image that captures the complete state and data of a virtual machine at a specific point in time. The state includes the power state of the VM (powered-on, powered-off, or suspended), and the data includes all the files that make up the VM (disk, memory, and other devices). It is a quick and efficient way to roll back VM to a specific point in time, just like the undo function.
In Microsoft Hyper-V environments, snapshots are also called checkpoints since Windows Server 2012 R2.
How do VM snapshots work
When taking a VM snapshot, all writable data will become read-only. You can take multiple snapshots for restoring the VM to multiple points in time. VM snapshots are not standalone, but depend on the parent VM disk or snapshot chain, and incrementally record changes since the last snapshot.
When you create a snapshot for the first time, the first child disk is created from the parent disk. Successive snapshots generate new child disks from the last child disk on the chain. The relationship can change if you have multiple branches in the snapshot chain.
Creating a VMware VM snapshot, you will create these files:
.vmdk file: a virtual disk file that contains the raw data in the virtual disk.
-delta.vmdk file: an incremental disk file that captures all changes made to the VM since the last snapshot was taken. It grows as the snapshot stays open and changes.
.vmsd file: a centralized file for storing information and metadata about snapshots.
.vmsn file: the snapshot state file that stores the current configuration and optionally the running state of a virtual machine.
These files are placed on the same storage infrastructure as the parent disks.
Note: Creating a Hyper-V checkpoint, you will create the following files:
- .vmcx file: the binary configuration file, that replaces the XML file found in 2012 R2 and earlier.
- .vmrs file: contains various information about the state of the running virtual machine.
- .vmgs file: used to store the virtual machine guest state in version 8.2 and higher Hyper-V virtual machines.
- .avhdx file: the differencing disk saves a specific state of virtual hard drive, used to make up a timeline with other .avhdx files in the chain. Once a checkpoint is deleted, the differencing .avdhx file is merged with the .vhdx file.
- .rct file: tracks change between backup operations, allows backup solutions to only have to copy the changes since the last backup.
- .mrt file: helps to provide resiliency in case of a host crash or BSOD of the host.
What is Virtual machine backup (VM backup)
A VM backup is an independent copy of part or all of the data in VM, that is not dependent on the original VM. Therefore, VM backups can be safely stored offsite, to the cloud, or other locations. This is the most commonly used measure for VM data protection.
How do VM backups work
VM backups can be divided into 2 types depending on how they work: image-based backups and file-based backups.
Image-based backup is an image that captures the current state of the entire virtual machine, backing up the virtual machine's operating system, configuration files, and all data on disk. File-based backups back up a virtual machine as if it were a physical machine by configuring an agent on the guest machine. You can choose what to back up yourself, but it only protects the operating system and applications, you can't restore the virtualized environment.
VM snapshot vs. backup
VM backup and snapshots can both be used to secure virtual machine data, but they work very differently. Many users have been confused by them. Therefore, in this section, I will analyze what are the differences between a snapshot and a backup.
- Data security: While VM backups are independent of the original VM, and can be safely stored offsite, to the cloud, or other location, snapshots depend on the parent disk. If the parent disk is deleted, the snapshot itself is not sufficient for VM restore.
- Performance affecting: VM snapshots are not suitable for long-term preserve, for the incremental disk file grows and can take a lot of space, affecting the VM performance. VM backups can be safely stored for long time without affecting VM performance.
- VM Restore: VM snapshots can only be used to roll back the original VM to the point of time the snapshot was taken. Whereas backups can be used to create single or multiple new VM to original or different location, without the original VM.
- Creating speed: Creating VM backups is slower than creating snapshots. The more data is backed up, the longer the process takes.
Can VM snapshot be used as backup?
The answer is NO. Snapshots can be used to roll back VMs, but cannot be used as backups.
As described above, a VM snapshot is dependent on the parent disk. If the parent disk is deleted or the virtual or physical infrastructure fails, the snapshot itself is not sufficient to restore the VM. A VM backup, on the other hand, is a complete copy independent of the parent disk, it will not be affected and can be used to restore the VM.
Besides, after taking a VM snapshot, all changes made to the VM will be stored in the incremental disk file. Therefore, snapshots can also take up a lot of disk space, and keeping them for a long time will affect the VM performance. But VM backups can be kept for a long time without affecting the original VM.
Proper use of VM snapshot & backup
VM snapshots are not recommended to be used in production environments. You can use them as quick failsafe before performing development or testing, to be able to roll back in case of any problem.
Keeping snapshots for long time can affect the VM performance. Therefore, VMware recommends using only 2-3 snapshots in a chain, and for single snapshots no more than 72 hours.
VM backup is a comprehensive data protection measure for every situation. While file-based backup is appropriate when you only need to back up a small amount of data on the VM, image-based backups are more complete and safer for disaster recovery. Implementing a proper automated backup strategy can maintain your business continuity, and go a step further in securing your VM.
In practice, it is recommended to use VM snapshots in combination with backups. VM snapshot can used as a short-term, temporary rollback measure before unsafe operations, while VM backup is used as a long-term, stable VM protection for disaster recovery.
Steps to properly create, restore and delete VM snapshots
After knowing what VM snapshots and backups are and their proper usage, now you can create them according to your actual needs. In this section, I will demonstrate the specific steps to create, restore and delete VMware ESXi VM snapshots as an example.
How to create VMware ESXi VM snapshots
1. Access VMware ESXi Web Client, and navigate to Virtual Machines. Right-click on the VM name and select Snapshots > Take snapshot.
2. Provide a Name and Description for this snapshot. And select to Snapshot the virtual machine’s memory, or Quiesce guest file system (needs VMware tools installed).
- Snapshot the virtual machine’s memory: record the VM’s memory, allowing you to roll back the VM to the exact running state when the snapshot was taken, but takes longer. If you leave this option unchecked, then the VM will be powered-off after you roll back.
- Quiesce guest file system (needs VMware tools installed): pause the state of the processes that are running, or may modify the information stored on disk when the snapshot was taken, to guarantee the consistency. Quiescing and Memory snapshots are mutually exclusive.
3. Click Take Snapshot to start. You can check the progress in Recent Tasks.
How to restore VMware ESXi VM snapshots
1. Right-click on the VM name and select Snapshots > Manage snapshots.
2. Select the target snapshot and then click Restore snapshot.
How to delete VMware ESXi VM snapshots
Deleting a snapshot will consolidate the changes to the VM and remove the snapshot. You should always remember to delete snapshots, when you want to keep the changes after the snapshot and will not restore to it.
1. Right-click on the VM name and select Snapshots > Manage snapshots.
2. Select the target snapshot and click Delete snapshot.
Steps to properly and quickly create and restore VM backups
Actually, there is no standard native way to backup VMware ESXi VMs. As you can see, there is no built-in “backup” option. Right-click on the VM and select Export or manually download VM files in datastore can keep a copy, but they require manual operations and can only backup one VM at a time.
Therefore, I will introduce you a professional backup tool that allows you to automatically backup multiple VMs at once, AOMEI Cyber Backup.
Except for automatic multiple VM backup, AOMEI Cyber Backup allows you to restore the backup to new VM on original location, or to another datastore, host. You can use this feature to clone multiple same VMs for further tests.
Next I will demonstrate how to backup and restore VMware ESXi VMs as an example. You can click the following button to start a free trial.
3 simple steps to backup and restore VMware ESXi VMs
1. Bind Devices: Access to AOMEI Cyber Backup web client, navigate to Source Device > VMware ESXi > + Add VMware ESXi to add a host, and then click … > Bind Device.
2. Create Backup Tasks: Navigate to Backup Task > + Create New Task, and set Task Name, Backup Type, Device, Target, Schedule, and Scheme.
- Device: using AOMEI Cyber Backup you can backup multiple, or even all VMs on the host at once.
- Target: You can select to back up to a local path, or to a network path. Used paths will be saved in Favorite Storage for handy selection.
- Schedule: You can choose to perform full, differential or incremental backup, and automate execution daily, weekly or monthly according to the frequency you specified.
- Cleanup: You can specify a retention period, and the old backup files that exceed the period will be automatically deleted.
Click Start Backup to select to Add the schedule and start backup now, or Add the schedule only.
3. Restore VM from Backups: Click … > Restore on the left of the backup task to open the restore wizard, click Select Content to specify a recovery point, and then select to Restore to original location or Restore to new location. Click Start Restore.
Being able to roll back virtual machines after failures, VM snapshots can also be used for data security. However, they still cannot replace VM backups. In this article I explained what VM snapshots and backups are, analyzed the differences between them, and demonstrated how to properly use them. Hope this could be helpful to you.
Except for the basic operations I introduced, there are more about snapshots you can explore, for example, schedule VMware snapshots. Backing up your VMs regularly and you can enjoy them freely.