Monday, March 31, 2014

Snapshotting - Preserving Moments in Time

So, now that you have your virtual machines, you are feeling empowered to go and do lots and lots of changes! Maybe take a crack at some major installation. Maybe even create an application or two to get your feet wet.

But what if you make a mistake? What if you really screw up your machine (and, these being Linux, fixing them won't be completely trivial!)

In a later post, I will talk about SVN but, for now, you best defense is to take a "snapshot" of the current state of the machine. Notice, you are preserving the "current state of the machine." Best way to think of that. If your machine was on and you were in the middle of a query when you took a snapshot, THAT will be the state of the snapshot!

With these snapshots, you have the ability to "recover" the snapshot; basically taking your computer back to the state of the machine when the snapshot was made. If it was in the middle of a query, it will go back to that time and then resume the query!

Let me show you what I mean.

Here I have my machine before I have done any snapshot.

Note the icons on the bottom left and the terminal window is open.

In my "use case," I have decided to clean up the desktop and start up a "sqlplus" session (you don't need to know what sqlplus is for this - just using it as an example)



Before I do anything drastic, I create a snapshot.

In Virtual Box, on the host, I select the machine I am working with and then select "Snapshots" (on the right).
I don't have any at this point, so all I see is the current state.

I click on the camera and I get to this image, below.

The original "Snapshot Name" is "Snapshot 1"
I am not going to stick with that. Instead I give the snapshot the name "Initial State." That name is really enough. If the snapshot was more involved, I would be tempted to add a Description.

After I click on "OK," there will be a little bit of processing but I will eventually see the following.


And now I have a Current State that is different (by 11 seconds) to the "Initial State!"
So, now that I feel confident about my "backup," I go to town on my desktop.

I deleted the icons and started SQL*Plus.
I then take a snapshot - for not really a good reason ... just because it was fun!
(Seriously, it would be a good idea to do a snapshot after any significant change you make in the system)

I now have TWO states (THREE if you include the Current State).

OH NO!!! I realize that I needed those icons!

Important to note I can't choose which bits of a snapshot I want to restore. It is an all or nothing thing. I am restoring the STATE of the machine at the time the snapshot was made.
Also important to note that you can't restore a snapshot while the machine is up and running, either! You can snapshot with the machine up (hot) or down (cold). Restoring is like revenge, it is best (and only) done cold!

So I bring the machine down (ideally by a good "shutdown.")
I then click on the state/snapshot I want to restore.

I will get a warning and the offer to make a snapshot of my current state (without the icons). You can decide for yourself if your shame is worth keeping! :) (if you want to make a snapshot - this is important because, if you don't, that state without the icons will be gone FOREVER.)



Now I have Virtual Box look like this...


When I start it up, it now looks like it's been restored to the initial condition!


There is so much more you can do here! Consider looking at the actual manual for virtual box -
http://www.virtualbox.org/manual/
http://www.virtualbox.org/manual/ch01.html#snapshots
- Or just Google around! Lots of good (and not so good (like mine!) info out there!

Have fun!




No comments:

Post a Comment