Let’s say you have set up a fully functional Centos 7 machine for your development work. You have installed development tools, Linux packages, build-essentials as part of your work. Down the line, you messed up something in your operating system by changing some important configuration and your OS is not booting up properly.
At this moment if you don’t have any backup to your machine then all your work is lost and you have to build the machine from scratch. This is where snapshots come in handy. Every virtualization software has the features of snapshots.
[ You might also like: Getting Started with VirtualBox in Linux ]
Snapshot is a point-in-time copy that allows us to save the state of the machine and can restore the machine state whenever needed using these snapshots. Virtualbox manager provides an easy-to-use interface to handle snapshots.
Creating Snapshots in Virtualbox
You can take a snapshot when the machine is in running or powered off state. There will be a difference with snapshots when you take in two different states. When you take a snapshot when the machine is running, the snapshot will be taken to whatever state your machine is in at that point. All the applications running, tools you have opened in your machine all will be captured.
To work with snapshots, select your virtual machine and click the icon as shown in the below image.
Once you open the snapshot menu you will have the below options to take control of your snapshot. In the below image, you can see there is a “Current State” that is your current running Guest machine state.
To take a new snapshot press the “TAKE” icon or press “CTRL+SHIFT+T”. You will be prompted to enter a snapshot name and description for your snapshot.
Once you click the ok button you will see the snapshots as shown in the below image. I have also taken couple more snapshots after installing few packages.
The snapshots are stored under your VM installation directory. You can find a directory called Snapshots where all your snapshots
.vdi files are created.
$ ls -f $ ls -f Snapshots/
Restoring Snapshots in Virtualbox
Now you can switch back to your previous virtual machine state by restoring the snapshots. Go to Snapshot manager, select the snapshot you want to switch to, and press Restore.
Now the snapshot will be restored and when you start the machine it will start from the current snapshot you restored. See from the below image the current state it now derived from the restored snapshot.
Removing Snapshots in Virtualbox
To remove the snapshot, go to the snapshot manager and select the snapshot, and press Delete Icon. It will remove the snapshot.
In the next article, we will take a look at how to clone your virtual machines in VirtualBox.