VirtualBox Snapshots from Command Line

Creating a snapshot of your VirtualBox VM is easy to do from the GUI tool but did you know it is also just as easy from command line? This is one of the most powerful features of any VM system and it should be a common practice that you use before upgrading anything on your VM.

In a perfect world, upgrading software on a virtual machine would always go smoothly but in the real world, every now and then you get a complete failure. Maintaining a backup of the VM virtual disk is one thing, but having a snapshot that you can roll back to is priceless. So yes, you can keep copies of your virtual machine’s .vdi or .vdmk disk image and restore from that, but snapshots are more convenient and built-in.

Snapshots allow chaining so that you can take snapshots inside of snapshots. This gives you a tight control over changes to your VM and providing an easy way to roll back to various points in time.

In these examples, we’re going to use a virtual machine named testvm. The idea is to take a snapshot of testvm prior to updating the operating system on the VM.

Take a snapshot of the VM and name it before-update. This can be done while the VM is running or stopped.

VBoxManage snapshot testvm take before-update

Restore a snapshot of the VM. This reverts all changes to the VM from the point of taking the snapshot.

VBoxManage snapshot testvm restore before-update

Delete a snapshot of the VM. When your updates are complete and good, free up some space and delete the snapshot.

VBoxManage snapshot testvm delete before-update

List the snapshots to see what is available.

VBoxManage snapshot testvm list

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.