25

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.

32

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>
| improve this answer | |
  • 8
    Note: the restore snapshot button will only be enabled when the VM is powered down. – Oliver Dungey Mar 5 '18 at 17:08
  • Saved my day :) – Ram Mar 21 '18 at 17:52
  • Also useful. Viewing available snapshots while on the command line can be done with vboxmanage snapshot VM_NAME list – Mitchell van Zuylen Apr 19 '18 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. – Will Matheson Mar 18 at 22:57
  • @WillMatheson thanks, updated shots. – Takkat Mar 19 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy