Question about incremental snapshots and replication

Dunuin

Contributor
Joined
Mar 7, 2013
Messages
110
Hi,

I'm a little bit confused how incremental snapshots work.
I created a manual Snapshot with prefix "Initial".
I setup a "Periodic Snapshot Task" with prefix "auto" to create a snapshots every day and keep them for a week. The idea was that I have one week to restore any files I deleted by accident or if I get a target of ransomware.
As far as I understand a snapshot stores the differences from now to the last created snapshot so I need all snapshots previously created until that snapshot to restore it.
So if the snapshots are "Initial" -> "auto_1" -> "auto_2" -> "auto_3" -> "auto_4" -> "auto_5" -> "auto_6" -> "auto_7" and I want to restore the state of my dataset of snapshot "auto_3" I need to have "Initial" and "auto_1" to "auto_3" to be able to restore it.

What happens after 1 week?
Will Freenas automatically delete all snapshots with "auto" prefix older then 7 days ? So that at day 9 I have just the snapshots "Initial" -> "auto_2" -> "auto_2" -> "auto_3" -> "auto_4" -> "auto_5" -> "auto_6" -> "auto_7" -> "auto_8"?
How is FreeNAS able to restore a state if "auto_1" is missing?
Or is Freenas merging "auto_1" and "auto_2" so it isn't possible anymore to restore the state of "auto_1" but all changes between "initial" and "auto_2" are merged into "auto_2"?

Also I want to backup some of my pools manually to USB-HDDs. I found some scripts and these do that by first creating a new snapshot, sending them to the USB-HDD and then do a replication. This is done incrementally and if I delete a snapshot before sending it to the backup drive the replication isn't working. The script is deleteing old snapshots by itself after replication.

How is that interfering with the "Periodic Snapshot Tasks"?

For example:
The backup script creates snapshots with the prefix "backup".

After week one it should look like this:
"Initial" -> "auto_1" -> "auto_2" -> "auto_3" -> "auto_4" -> "auto_5" -> "auto_6" -> "auto_7"

Then I do a manual backup by running the script:
"Initial" -> "auto_1" -> "auto_2" -> "auto_3" -> "auto_4" -> "auto_5" -> "auto_6" -> "auto_7" -> "backup_1"

Then "zfs send" is used to send "backup_1" to the USB-HDD for replication.

2 weeks later the snapshots should look like this:

"Initial" -> "backup_1" -> "auto_15" -> "auto_16" -> "auto_17" -> "auto_18" -> "auto_19" -> "auto_20" -> "auto_21"

If the script is now run again and creates a new snapshot "backup_2" and uses 'zfs send -i "foobar@backup_1" "foobar@backup_2" | zfs recv "pool/foobar_backup"' is that working? Because between the two backups there were the snapshots "auto_8" to "auto_14" but they are already deleted by the "Periodic Snapshot Task".

Is it possible to somehow use snapshots to revert to recent changes on a small interval scale and also use snapshots to backup the same datasets to an other pool on a unregular long interval like once every 1 oder 2 months?
 

Dunuin

Contributor
Joined
Mar 7, 2013
Messages
110
After some hours of youtube research I found out that it is important that if you want to mirror a pool to another server via a replication task and periodic snapshots, you have to make sure that every snapshot is replicated before it is automatically deleted.

But what happens with manual snapshots via a backupscript if the backup script is creating manual snapshots and only deletes them after a replication is done like here:
zfs snapshot "foo/bar@backup_Initial"
zfs send "foo/bar@backup_initial" | zfs recv "backuppool/bar_backup"

zfs snapshot "foo/bar@backup_2"
zfs send -i "foo/bar@backup_initial" "foo/bar@backup_2" | zfs recv "backuppool/bar_backup"
zfs destroy "foo/bar@backup_Initial"

zfs snapshot "foo/bar@backup_3"
zfs send -i "foo/bar@backup_2" "foo/bar@backup_3" | zfs recv "backuppool/bar_backup"
zfs destroy "foo/bar@backup_2"

Is it possible to have a periodic snapshot task running which creates and deletes "@auto_xyz" snapshots" between the "@backup_xyz" snapshots as long as the "@backup_xyz" snapshots are untouched?
 
Top