In this video, you'll learn about Stratis Snapshot.
Now, a Stratis Snapshot is a metadata copy
that allows you to access the state of the snapshot
at any time.
It's not a backup, but it can be helpful in accessing
deleted files.
A snapshot is mounted by its device name, not by the UUID.
Now, let me show you in this demo
how you can work with a snapshot.
And this demo should help you understand why
snapshots can be convenient.
So I'm going to start with dd ifs slash dev slash 0.
Ofs slash myfs slash big file.
Bs is 1m.
And count is 2,000.
I want to write a 2-gigabyte file on the Stratis volume.
So now I'm using Stratis pool list.
And in Stratis pool list, we can see
that there is only 38.93 gigabytes free,
and we have 1 gigabyte that is used.
Now, that is kind of funny, but that
is because the data is still synchronizing.
It takes a while before you can see the file being
committed to the Stratis pool.
That is because of the way how Linux is writing.
When you write something, it's first
committed to the buffer switches in memory,
and then from the buffer memory, it
will be synchronized to disk.
And as you can see, that has now more or less happened.
Good, Stratis FS list is also showing
that 2.5 gigabytes is used, half a gig for metadata
and 2 gig for my big file.
Now, I'm going to use Stratis FS snapshot
to create a snapshot.
So I create a snapshot in my pool of my FS,
and the name of the snapshot is myfs-snap.
And now, Stratis FS list is showing that I have the snapshot,
and the snapshot is now identical to what
we see in the original file system.
So now, I'm going to use RM to remove myfs-big file.
And oh, no, I removed this important file.
Well, that is what you have to snapshot for.
The snapshot is a picture of the current state of your file
system.
So in the snapshot, we should still
have access to this big file, and that's
what I'm going to show you right now.
Using mkdir slash myfs-snap.
Next, I'm using mount dev-stratis mypool myfs-snap
on the directory slash myfs-snap.
And I'm using ls minus l slash myfs-snap.
And what do we see?
We see that big file still exists.
Now, obviously, a snapshot is not a backup,
because snapshots are depending on the original volume.
If you delete the original volume,
then everything is gone.
But snapshots are a protection that
helps you if anything was removed since the time
you last made your snapshot.
So it's like a backup light.
Now, once you are done with your snapshot,
it is wise to use status fs destroy mypool myfs-snap,
because if you don't delete it, well, it
will just consume disk space, and that doesn't work well.
And oh, boy, what do I get here?
Well, I get a classical error.
As you can see to the end of my command,
we have device or resource busy.
You know why?
Well, that is because it is mounted at the moment.
So let me use you mount on myfs-snap,
and then I can destroy the snapshot.
And now it's gone, and we are back to the original situation.
And that's how you can use status snapshots.