Mirroring and snapshots.

MarkusH

Dabbler
Joined
Jul 4, 2023
Messages
11
So a snapshot is basically a temporary copy of a file stored on the system. And mirroring is basically a backup of the other drive right. So if a drive gets corrupt or something in that way, It would be mirrored to the other drive or could you use the other drive to restore original? Basically asking if mirroring only helps if a straight up dies and its used to restore to a new drive, and snapshots are meant for curruption of files and accidental deletion? I have a mirror setup with 1tb ssds and a 250gb ssd for OS, any advice for snapshot settings (how often should it be updated?)
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
So a snapshot is basically a temporary copy of a file stored on the system
Not really.

A snapshot is a copy of the file table at a point in time, which means that all of the blocks involved in storing files in that filesystem at the time of the snapshot are protected from being overwritten/deleted.

You can access that snapshot to look at files from that point in time or use it to transfer that moment in time version of the filesystem somewhere else, but it isn't a second copy of the data until you do something like that.

And mirroring is basically a backup of the other drive right.
Not exactly either.

Both members of a mirror will (as long as everything is healthy) contain the same data and don't need the other in order for a copy of the data to be available for reading/writing.

Mirrors are specifically not a backup as both sides of the mirror contain the live filesystem (and snapshots) only.

Mirrors are more often considered useful for their IOPS performance and used instead of other options which reduce the IOPS available to the system per disk.

So if a drive gets corrupt or something in that way, It would be mirrored to the other drive or could you use the other drive to restore original?
Because ZFS has built-in checksums, corrupted isn't a thing that can happen without you knowing about it, so you can be fairly certain that corrupted data won't get mirrored to the other side of the mirror as all read operations involve consulting the checksum.

If corruption is noticed by ZFS and there's a non-corrupted copy available, self-healing will happen (and should be forced to happen with regular scrubs on pools where you care about the contents).

Basically asking if mirroring only helps if a straight up dies and its used to restore to a new drive, and snapshots are meant for curruption of files and accidental deletion?
That's sort-of the principle, but as explained above, snapshots aren't copies and mirrors are more than just a protection against failure (but they also do that).

I have a mirror setup with 1tb ssds and a 250gb ssd for OS, any advice for snapshot settings (how often should it be updated?)
How much time/data are you prepared to lose?

Snapshots don't cost much in ZFS as they represent just a copy of the file table (mere cents on the dollar... or even less than that), but they will block freed space from being used when files have been deleted since the snapshot, but the snapshot is retained, so you need to consider that in your retention timing.

You can't keep everything forever for free...

If you have a heavily used file share with lots of changes going on during the day, you might do hourly or even 15-minute snapshot intervals between 8:00 and 18:00.

Depending on how long you think it would take to realize that something's wrong/unintentionally deleted, you might set the retention for snapshots to 2 weeks.

Remember that this would mean if your pool fills up, deletion of files will take 2 weeks to return the space to you (unless you manually delete all snapshots that contain the deleted files).
 
Top