Welcome back to vSphere 8 in the real world.
And now we're going to discuss snapshots.
So a snapshot is not really a copy of a VMDK.
What a snapshot is, it's a delta of a VMDK.
So let's say we have a virtual disk, right?
And so in VMware, our virtual disks are VMDK files.
And if our VM is called demo one,
then we have a file for the hard disk.
By default, that file would be called demo1.vmdk.
And that is the virtual disk, that first virtual disk
for this particular virtual machine.
And when I write a file to that virtual machine,
it gets written to that VMDK.
If I delete a file off the virtual disk,
it gets removed from within that VMDK.
But it's all written within that one file.
What can happen is I can decide I want to take a snapshot.
And when I take a snapshot, what happens
is that VMDK file now becomes a read-only file.
I'm not going to write any more changes to that.
A new file is going to get created.
That's going to be my delta file.
So I'll have my demo1.vmdk.
And I'll have another file called delta1-0000,
for exactly the number of zeros, 1.vmdk.
And that series of zeros, 1.vmdk, that's my delta file.
That's my first delta file.
So I have my primary file that is now my read-only file.
And then I have that delta file.
Now what happens, when I want to read something
from that virtual disk, it reads it
from that original file, that read-only VMDK file.
But if I open up a Word document from there,
I just read it out of that read-only file.
I open it in Word.
I start making changes to it.
I click on Save to save my changes.
Those changes don't get written to that read-only file.
They now get written to that delta file.
So in the operating system, the guest operating system says,
oh, I want these certain blocks that have that Word document.
The hypervisor knows, oh, those blocks that are pointed here
are actually now in this other file down over here.
And as I open files and make changes to the files
and save those files, they get written to that delta file.
And that delta file starts to grow.
So what can happen is maybe my original disk was 100 gigs.
And of that 100 gigs, 50 gigs of it
is documents and files and pictures and things like that.
Over time, if I never deleted that snapshot
and I touched every single file that
was on that virtual disk, all of a sudden,
this disk is 100 gigs, which is maybe
the max size for that virtual disk, or close to.
And my delta file is now 50 gigs,
because that 50 gigs of files up here
all got changed and written to that delta file.
And then over some time, OK, I'm writing changes
and I'm doing things.
Everything's going fine.
I take another snapshot.
Now I get a demo1-00002.vmdk.
And when I say I want to read operating system
files that haven't changed this entire time,
I'm getting those from that first original vmdk file,
demo1.vmdk, and I'm reading those
and I'm running the operating system.
But when I want that Word document that I changed,
that goes to that first snapshot file,
the 00001.vmdk, which is now read-only.
All I can do is read from it now.
If I create another snapshot, I read the file from there.
I go in, I make changes, I click on Save,
and the changes get written to my second delta
file, my 0002.vmdk.
Now I've got two snapshots.
One is read-only and two is the one I can write to.
And maybe that grows, and I change 10 gigs of data
over this time, and it gets written to that second file.
Then I create a third snapshot.
And you can kind of see what's happening now.
My original VM that was 100 gigs,
and I've got 100 gigs of data, is now
taking up 150 gigs, 170 gigs, 200 gigs.
And I create more snapshots, those snapshot files
start to grow, and I create more snapshots,
those snapshot files start to grow.
All of a sudden, this little simple 100-gig virtual machine
is taking up 1,000 gigabytes of space on my storage array.
So I keep taking snapshots and not deleting them.
So one, I'm not using my storage very efficiently.
Secondly, what happens is it will say,
oh, you want this file here.
Oh, but actually, it's pointing to the snapshot one.
Snapshot one points to snapshot two.
Snapshot two points to snapshot three.
Snapshot three points to that snapshot four.
Oh, here it is on four, or here it is on five.
That all took time.
And so now, my performance is really starting to lag.
I'm not using my space efficiently.
My performance is lagging.
And it's not unusual.
For some reason, in the middle of that, my snapshot three
is supposed to point to snapshot four, and that pointer breaks.
And all of a sudden, now my snapshot chain is broken.
And everything below that snapshot chain is lost.
And my VM won't even start up anymore,
seeing that happen more than once.
You can go in there.
It can be fixed.
You can manually edit and try and fix that.
I've heard of, never used one myself, third-party tools
that you can use to try and find all your snapshot chains
and fix them for you.
A lot of times, it's kind of a manual
go-in-there-and-fixing kind of process.
So creating snapshots, and snapshot
after snapshot after snapshot, and not deleting them
is a really bad practice.
I recommend that if we're taking snapshots,
and one of the more common reasons
why is we're installing updates.
I'm updating the operating system.
I'm updating an application.
Maybe I'm making the change to some data in an application.
And I'm like, OK, this is like maintenance type of changes
to my data.
I've taken the database offline.
I'm going to do some maintenance,
make some changes.
But I'm worried that I might end up screwing this up.
I'm going to take a snapshot.
Go in there and make my changes.
Test.
Everything's good.
Delete my snapshot.
Test.
It's bad.
Roll back my snapshot and delete that snapshot.
Roll back to what I had and delete the snapshot.
So you have a way of recovering.
What snapshots, though, are not, and they
get confused for this often, they're not a backup.
Because as an example, I just mentioned,
if that snapshot chain were to break,
I could have lost that VM and all the data
that would be on that VM.
It won't start up now.
So how do I recover from that?
Well, maybe you can fix the chain.
Or you can go to your backups and restore that VM
and get it back up and running.
Snapshots are not a backup.
If there's a corruption somewhere
in that virtual machine chain, the snapshot
does not fix it for you.
You can roll back and lose data maybe.
Maybe the break is somewhere low in the chain.
And you can roll to up earlier before it
and just lose everything below that.
That's not a backup.
So snapshots are not backups.
They're just a place and time holder
that you can roll back to.
So they are kind of a safety measure against changes
you didn't really want or changes that messed things up,
an update that screwed things up.
But they're not a replace for a backup.
Whereas if you had a true backup and that storage got corrupted,
that virtual disk got corrupted, you
have an entire copy of that VM someplace else
on different storage that's not corrupted
that you can restore that VM from.
So snapshots and backups are not the same thing.
They get often confused for being
similar to the same thing.
They're not the same thing at all.
One is just a place and time holder
for a certain configuration.
The other one is an actual protected copy
of your virtual machine, the operating system, your data,
your applications, all those kinds of things.
That's a backup.
So don't confuse snapshots for backups.
So snapshots are fantastic for I'm going to run some updates.
And before I update Windows, we take snapshots.
That's fantastic.
OK?
So to take a snapshot is pretty easy.
You just go to the VM that you want to snapshot.
You're going to right click on that one.
Go to your snapshots.
And you can just say take snapshot.
And when in there, you can go in there and give it a name.
It's really a great idea not to use
the default name, which is basically
like the virtual machine name and update and timestamp.
Something descriptive, especially
in the description, a longer description,
but even in the name, you might say
before installing Windows Update and the date and time, right?
Or before installing new antivirus and a date and time.
You might put some detail about why you're taking a snapshot.
This is before this.
This is after that.
Things like that.
Snapshots are super helpful for that kind of thing.
So maybe we're going to go in and say
before installing new antivirus.
Well, if you're installing a new antivirus,
you probably uninstalled your old one, right?
So take a snapshot before installing old antivirus.
Then after, take another one, after uninstalling
your old antivirus.
Then before installing the new one is your after,
after installing new antivirus.
Then take another one, updated the virus definitions
or updated the version or something like that,
ran a complete scan with antivirus.
So I'm taking a snapshot before I run a complete scan.
So doing one simple task of uninstalling your old antivirus,
installing the new antivirus, updating the definitions,
running a complete scan of the system with the new antivirus,
you might take four or five snapshots
because maybe somewhere along the way,
something was sideways.
So I want a snapshot of my VM before I uninstalled the old.
I want a snapshot after I uninstalled the old
before I installed the new.
And then I want a snapshot with the new
before the new definitions
because where did this go sideways on me?
Sometimes things are going wrong.
Like where did this go wrong?
Let's roll back to here and see what's going on.
Okay, here we're fine.
Okay, let's roll back to here.
Here we're fine.
Oh, let's go to here.
Oh, when I get to this point here,
this is where things start to break, right?
So you want to have a record, you know,
and a way of going back to these different points in time
and checking that out.
So your name should be descriptive of where you are.
And then the actual description can be even more descriptive,
more detailed.
But you want to be able to look at the name real quickly
and figure out where you are.
You can also go in and rather than say take a snapshot,
you want to manage a snapshot.
So there it will show you the original virtual disk
and then each of those snapshots,
those deltas will be listed below that
and it'll tell you where you are.
If you're down at the bottom,
if you just keep taking them and taking them,
you never do anything else, it'll say you're here,
you're after that last snapshot.
Or maybe you went and said, okay,
so I, you know, have my antivirus.
Here's where I uninstalled my antivirus.
Here's where I installed the new antivirus.
Here's where I updated my definitions.
Wait, something's wrong.
Without deleting these snapshots,
I can click on one,
maybe I go back to after I uninstalled the antivirus
and before I installed the new.
I can jump to that point in time,
revert the machine to there.
I still have those snapshots below
and I can say, is everything good here?
Yeah, everything's good here.
All right, let's jump to the snapshot
where I have the antivirus installed.
Okay, so I click on that one, I say jump to here.
Is everything good?
Yep, everything's good here.
All right, so let's look at
after we updated the antivirus definitions.
I go to there, everything good?
Everything's good here.
And you can keep stepping through there.
So you can go up and down through that chain of snapshots
from the manage option.
And then revert means you want to revert.
Consolidate means that I want to delete one
and consolidate it into the one above.
So I only have the one.
I'm deleting one and consolidating into another one.
And then delete will actually just roll it up, right?
And so I can say I want to delete all the snapshots.
If I go in and say I want to delete all the snapshots,
it's going to take the state I'm in
and roll it up into the main VMDK file.
So let's go back to that example
where I have my main demo1.vmdk
and then I have my snapshot1, my snapshot2, my snapshot3
and I'm running down below snapshot3.
Everything's running fantastic.
Everything's running good.
I'm like, all right, I've run all my tests.
I'm happy.
This is where I want to be.
I trust this configuration.
I'm going to say delete all.
What happens is it's going to write the changes
that are in Delta 1 to that VMDK.
And then it changes in 2 to that VMDK
and then 3 to that VMDK.
The more I have, the longer it's going to take
to roll all that up.
When I'm done, I'll end up with that 100-gig disk
and just that 100-gig disk and not all the Deltas below it.
But the more I have, the longer it's going to take
to roll that all up.
So again, having too long a chain
and too big of Deltas can make deleting snapshots
take a while.
If you only run them for a few hours,
a day or two at the most,
I usually try to run them for a few hours.
Depends on when I'm testing.
Maybe like a Windows update,
I need to run sometimes longer.
I want to run for a couple of days or so.
But not more than that.
I try to never run a snapshot
for more than a couple of days.
Now that we discussed snapshots,
let's go ahead and jump into our demo environment
and actually create and manage some snapshots.
So here we are back in our demo environment.
And our demo environment is, again,
being ran in VMware's hands-on lab.
So it's hol.vmware.com
for VMware's hands-on lab environment.
And I went in and just created a clone
of this Windows 10 machine.
And I called it Demo01.
And over here, I have the datastore
that that Demo01 is in.
And if we look through here,
we see we have our virtual swap
and some non-volatile RAM.
Here's my VMDK file, right?
My Demo01.vmdk, all right?
And that's pretty much the only VMDK
I've got on here.
If I go back over here
and right-click on this VM
and say I want to go to snapshots,
take a snapshot, and what is this?
I'm going to say this is my first lab
and my date and the time.
I always kind of create a description,
a brief description,
and I note it with the date and time.
So, I might say it is April 3rd in the year at 1226.
And actually, the time, the hour,
and the minute is actually really important
because sometimes the only difference in the date
and when you took it is maybe like 15 minutes later.
So, the date and time is really useful.
And then here I would do a detailed description
of the task and the date and time.
All right, so I've gone in.
I get a good detailed name with the date and time.
I get a good description of what I'm doing
and the date and time.
Include the virtual machine's memory.
What this is great for
is if I'm going to revert back to the snapshot later,
it won't have to restart.
If I don't have the memory and I revert to a snapshot,
it actually has to reboot the VM with that virtual disk.
If I include the RAM,
I can actually jump right to this moment in time.
When I click create, it's this moment in time
I'm reverting back to without a reboot
because I also know what the memory looked like
of that VM at this moment in time.
So, it's going to go in and create my snapshot.
And it does, even though it's only creating a delta file,
an empty delta file,
and, you know, kind of migrating any write changes to it,
it takes a minute to do this.
So, we'll let this run for a moment
and come back when it's complete.
So, that snapshot is completed.
So, now I'm going to go back to the folder
that has this virtual machine in it.
I'm going to refresh this screen.
Here's my demo one.
Notice that demo01-00001.vmdk.
This is my snapshot file, okay?
So, this is the delta file from this VMDK file, okay?
This is my VMDK file, and I have my delta file.
And it's about, you know, 19 megs or so.
It's pretty small.
As I open up that VM and start making changes,
it's going to read the files
that I'm wanting to change from the VMDK file.
Where is my VMDK?
Oh, here we go.
From this VMDK file, this is going to be the source.
This file is now a read-only file.
It's going to read from here.
And when I say save those changes,
when I write changes, create a new file,
write changes to old files, whatever it is,
they get written to this delta file.
If I go back to here, and I were, say, to go to snapshot,
and I can say manage snapshots,
it'll tell me, right, here's my first snapshot,
and I'm here.
I can still go in now, right,
and say I want to take another snapshot,
and I'll call this second lab snap, the date and the time,
and my description.
Okay, so I have a description of the second snapshot,
why I'm taking it, and the date and the time,
and I'm including my virtual machine memory,
and say create.
Again, this takes a moment to do.
It's going to go in there and create that file
and kind of change the original delta file,
write that 001 file to a read-only file,
and create me a new read-write file.
So here you can see I have my first lab snapshot.
Then I create that second one, and you are here.
So I'm writing, everything that's, you know,
getting written from this guy is being written to this file here,
because I am now, at this point in time, past that snapshot.
If I go to here and just refresh my screen
and go to my demo 01, you'll see I now have two delta files.
I have the original delta file, that 001 file,
and I have the 002 file, right, the demo01-000002.bmdk.
So this one here is going to be my new read-only.
Again, my first source file is going to be my first VMDK file.
If I can scroll and find it. There we go.
So this one is where it's going to go to when I say,
I want to read a file. It'll go to here to look for the file.
This file might point me, say, oh, those blocks actually now are here.
And if the file that I had changed from here
has now been changed and written here,
this one will point to this one, and then I'll get my document.
And this file is going to have all the changes written to it
going forward until I create a new one.
I can still go back to my snapshots, and I have this guy here,
but I can say, you know what, I want to go back to this guy here,
and I can revert back to this point in time, right?
I can say revert to there. You are here.
So now this is now my new point in time I'm running from, right,
to the moment when I created, or last wrote to this file.
I should have left that there, there.
And I'm now reading and writing from this 01 file.
Okay. I can say, all right, you know what,
I'm happy with this point in time that I'm at here.
I want to take this, everything I have, everything I have in this file,
and everything I've written since then, all of this,
I want to keep all of this, and I'm going to dump everything else after that.
So I'm going to say just delete all.
And it'll just consult it and roll up all of this
and throw out all of that.
And I just got rid of all those snapshots.
So now my 100-gig disk is again 100 gigs, if that's what my file is, right?
If I had been writing and creating more snapshots,
and my first Delta file got to 20 gigs,
and my second Delta file got to be even bigger, 30 gigs,
or smaller, only 10 gigs, whatever it is,
so that 100-gig VM ended up becoming 130, 140 gigs.
I deleted all my snapshots.
Now I'm back to a 100-gig virtual machine.
So that is pretty much how snapshots work.