26

I am running Ubuntu virtual machine on Ubuntu host machine using VirtualBox. I installed some softwares on my virtual machine. I wonder if there is a method to reset my current virtual machine to a given previous state (snapshot) of my choice? How can I do that? How can I reset to a previous snapshot undoing any changes I will make further to my VM?

Any method is welcome, especially the ones I can program either in a bash script or any programming language.

1 Answer 1

34

Take a snapshot

From the Virtual Box GUI (Virtualbox Manager) when Machine > Tools > Snapshots is selected we can easily take a snapshot from a running virtual machine by selecting Take Snapshot or pressing HOST+T:

enter image description here

This will open a dialog to give in a sensible name and optionally a description of this snapshot:

enter image description here

The snapshot will then be saved in the machine's directory (depending on the size of the machine this may take a while).

On the command line the same can be achieved by

VBoxManage snapshot <Name_of_VM> take <Name_of_Snapshot>

Restore a snapshot

From the Virtualbox Manager we can restore a shut down virtual machine to any snapshot by selecting a machine's Snapshots (1):

enter image description here

Select the appropriate snapshot from the list, then press enter image description here to restore this snapshot.

The current state of the machine will then be lost. To also restore the current state we will first have to create a snapshot too.

Restoring a snapshot from the command line is done with

VBoxManage snapshot <Name_of_VM> restore <Name_of_Snapshot>
4
  • 9
    Note: the restore snapshot button will only be enabled when the VM is powered down.
    – Oly Dungey
    Mar 5, 2018 at 17:08
  • Saved my day :) Mar 21, 2018 at 17:52
  • 1
    Also useful. Viewing available snapshots while on the command line can be done with vboxmanage snapshot VM_NAME list Apr 19, 2018 at 10:10
  • In version 6, the button to access snapshots and logs is inside the VM's button on the list in the left panel. Mar 18, 2020 at 22:57

You must log in to answer this question.