about snapshots and restoration

Status
Not open for further replies.

no1chan

Cadet
Joined
Mar 2, 2016
Messages
4
hi all, i want to ask a question about snapshots and restoration.
i want to know if the snapshots are incremental updates or not.
here is the scenario:
i have 1 dataset with 5 periodic snapshots created every 30 minutes, namely snapshot_1pm, snapshot_2pm, snapshot_3pm, snapshot_4pm and snapshot_5pm according to their creation time.
if i delete snapshot_3pm and snapshot_4pm, can i still restore them to 1pm version?
if yes, what is the theory behind of doing snapshots?
thanks ;)
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
if i delete snapshot_3pm and snapshot_4pm, can i still restore them to 1pm version?
Yes. In fact if you want to restore the 1PM snapshot specifcally, you must destroy the 2, 3 and 4pm first. You can only roll back to the latest snapshot taken.

if yes, what is the theory behind of doing snapshots?
First and foremost is the ease of restoration to a previous state. Another option is if you want something from a specific point in time you can clone the snapshot, grab what you need and then delete the clone without having to destroy all the incremental snapshots in between.
 

no1chan

Cadet
Joined
Mar 2, 2016
Messages
4
Yes. In fact if you want to restore the 1PM snapshot specifcally, you must destroy the 2, 3 and 4pm first. You can only roll back to the latest snapshot taken.


First and foremost is the ease of restoration to a previous state. Another option is if you want something from a specific point in time you can clone the snapshot, grab what you need and then delete the clone without having to destroy all the incremental snapshots in between.
thank you for your reply.
how about another scenario.
now it is 6pm and 3 and 4 pm snapshots have been deleted. can i restore to 5pm version?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
As long as the 5PM snapshot is the latest one yes.
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Yes, you can roll back to the previous snapshot. If you want to roll back to an earlier snapshot, then you must delete the ones between now and that snapshot. The deletion process incorporates the changes that are captured in snapshot being deleted, so you are just losing the ability to roll back to that point in time.
 

no1chan

Cadet
Joined
Mar 2, 2016
Messages
4
As long as the 5PM snapshot is the latest one yes.
if i can roll back to 5pm, that means the incremental update is done with respect to the current files but not the previous snapshots.

Yes, you can roll back to the previous snapshot. If you want to roll back to an earlier snapshot, then you must delete the ones between now and that snapshot. The deletion process incorporates the changes that are captured in snapshot being deleted, so you are just losing the ability to roll back to that point in time.
assume that no snapshots were deleted and i want to roll back to 1pm version. does it mean what the system does is to roll back to 5pm , then 4pm, then 3pm, then 2pm, and finally 1pm?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
assume that no snapshots were deleted and i want to roll back to 1pm version. does it mean what the system does is to roll back to 5pm , then 4pm, then 3pm, then 2pm, and finally 1pm?
You could roll each one back individually but why would you? Just delete the intermediate snapshots and then roll back the 1PM.
 

no1chan

Cadet
Joined
Mar 2, 2016
Messages
4
You could roll each one back individually but why would you? Just delete the intermediate snapshots and then roll back the 1PM.
thanks for your reply. i just want to know the philosophy of the implementation :cool:
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
if i can roll back to 5pm, that means the incremental update is done with respect to the current files but not the previous snapshots.
You are thinking of snapshots incorrectly. Taking a snapshot is nearly instantaneous. I'm pretty sure there is a ZFS Primer on the forums, but here's a quick explanation of copy on write and snapshots:
http://breden.org.uk/2008/05/12/home-fileserver-zfs-snapshots/
Copy-on-write
Just to clarify, ZFS uses a system called ‘copy-on-write’, which means that if a file is modified, ZFS will create a new file containing the modifications, then move the pointer to the new file and finally delete the old file, all in one transaction. But if the file deleted is referenced by one or more snapshots, then the data blocks occupied by the original file will become owned by the snapshots that reference the original file. In this way, when a file is modified or deleted, snapshots referencing the original file will consume disk space as they assume ownership of the original file’s blocks. But the file system in which the file existed will no longer reference the blocks used by the original file, but will reference the new blocks used by the new modified file.

Once you understand this copy-on-write mechanism and the way snapshots continue to reference the blocks used by the original files, you will have grasped the key to the magic of snapshots.
 
Status
Not open for further replies.
Top