Help me understand snapshots better

Status
Not open for further replies.

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
I'm trying to get a better understanding of snapshots and how they work. I've been burning up Google the last couple days but I'm still just not completely understanding it. I've found this place to be a concentrated location of VERY knowledgeable people when it comes to all things IT, computers and networking related so that's why I'm posting my question here. And since snapshots are one of the features of FreeNAS this is the perfect place to ask.

So far the best understanding I've found was described as a glass layering effect with each snapshot being like a new layer of glass with everything there but under the glass and not accessible unless you remove the top layer of glass. What I'm not quite understanding is exactly what happens when a snapshot is restored.

If I'm understanding things correctly when you roll back a snapshot it restores the previous data that was in place when the snapshot was taken. But what happens with the data that was added since the snapshot was taken? Can you roll back several snapshots to recover multiple layers of previous data? If there is data or files that have changes since the snapshot was taken do they stay the same or get overwritten?

I have a few more questions but I didn't want a novel for the first post so this should be enough to get a discussion going.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Theoretically, snapshots are trivial to read even while the current state is being accessed.

In practice, they're trivial to access via Previous Versions/Shadow copies on CIFS shares. This is, of course, non-destructive for current state and snapshots.

There seem to be some issues when accessing them directly, but I'll let someone who knows something concrete about that matter provide the details.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
The reason I ask about all this is I'm using a jail(s) for scratch space for installing a FEMP stack and discussion forum and to teach myself how to run it and maintain it. I'm wondering if snapshots will work to provide a backup in case I screw something up bad enough that I can't access what I'm working on. That way I can quickly recover from a snapshot instead of having to start over from scratch with a fresh jail.

I've played around with it a little bit today and it seems to work as I expect. But what if in the future I want to go live with the jail and end up having to restore a broken forum? Will a snapshot do that as I expect? If the latest snapshot doesn't work can I delete it and roll back the next one in line? Is deleting the most recent one the only way to roll back to previous ones? Does it work that way?

I'm not looking for something to replace a complete and proper backup, just something to quickly restore function if need be.

Does any of what I'm asking make sense?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
From what I understand if you delete a snapshot all the others snapshots are unaffected, please correct me if I'm wrong.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,525
Think of snapshots as but a "bookmark". It bookmarks your data in that dataset (or zvol) at that particular moment. That data will then be preserved until you delete all of the bookmarks that protect that data. If all bookmarks protecting that data are removed, then you end up with the only copy in existence being the copy that is "real-time". If there is no "real-time" copy of that data, then when the last bookmark was deleted, that disk space was freed at that time.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
So using your bookmark analogy you can permanently delete old data by deleting an old bookmark. I get that part. But if I understand correctly the only way to get to an old bookmark is to destroy the new ones correct? With snapshots you can only roll back to the most recent one correct? If that doesn't work then you have to roll back in succession or destroy the newer ones to get to an older state correct? Is there any way to "pick" which snapshot you want and then roll that one back without destroying newer ones?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,525
You can get back to the most recent snapshot by cloning or rolling back.

You can get back to *any* snapshot by cloning it. Cloning is like "mounting" a snapshot in a new location (you have to provide that location when cloning the snapshot).
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
I didn't know that, I'll have to experiment with this some more. Thanks for the info.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Ok I'm still not quite getting this. I've been playing with jails using them as scratch space for something I'm working on. I broke something tonight and so I rolled back the newest snapshot that I had and everything worked as planned. Well as I played around a little more I realized that wasn't the snapshot I wanted so tried cloning the snapshot. What it did was create another jail that was a clone of the current one. How do you then utilize that snapshot? I couldn't figure that out so I deleted the most recent snapshot I had and then tried rolling back to the one prior to that and it broke the jail.

Snapshots sure seem like a great idea but how do you utilize any of them other than the most recent one?
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
Ok I'm still not quite getting this. I've been playing with jails using them as scratch space for something I'm working on. I broke something tonight and so I rolled back the newest snapshot that I had and everything worked as planned. Well as I played around a little more I realized that wasn't the snapshot I wanted so tried cloning the snapshot. What it did was create another jail that was a clone of the current one. How do you then utilize that snapshot? I couldn't figure that out so I deleted the most recent snapshot I had and then tried rolling back to the one prior to that and it broke the jail.

Snapshots sure seem like a great idea but how do you utilize any of them other than the most recent one?
I think the best approach in this case is to replicate the snapshot of interest to a new dataset. If the new dataset is working, you can copy its content back into the original dataset so to keep your snapshot history. Well maybe not the best approach after all as it will require more pool space and it can be time consuming.
 
Status
Not open for further replies.
Top