Lifetime of snapshots

Status
Not open for further replies.

freenastier

Dabbler
Joined
Feb 9, 2017
Messages
20
I am a little bit concerned about my snapshot backup strategy.

I have a snapshot task that takes snapshots of certain datasets that I like to backup to a remote machine. These snapshots have a lifetime of two months. They are replicated to a remote machine running also freenas with the replication task.
What happens when the duration two month expires? Does the data inside these snapshots disappear on the remote machine?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
It depends what your replication job is set to do. If you set the option:

Delete stale snapshots on remote system:

to be ticked, your fear is well founded.

In order to allay your concern, uncheck the option.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Perhaps it doesn't need to be said, but will say it anyway...

With that check set to off, the storage required to continue backing up your primary storage will start to greatly exceed the storage used on your primary system.

I would assume your plan was to cater for that, but mention it just in case.
 

freenastier

Dabbler
Joined
Feb 9, 2017
Messages
20
I understand that I can not store everything indefinitely, but I do not want to loose data either.

So just to be clear:
1) If my replication task sends a snapshot of my primary system to a secondary remote backup system with a 'snapshot expiry' time set, then the data will be retained on the remote backup system even after the expiry time has passed?
2) When using the 'Delete stale snapshots on remote system' option however the data is deleted from the remote system when the expiry time has passed or when the original data is deleted from the primary system?

In case 2, what does trigger the deletion on the backup system? Is it the deletion of data on the primary system or the expiry time?
If data is removed on the backup system due to the expiry time, would it then not be recovered again by the primary system's replication task which sends newer snapshots to the backup system?
 

PhilipS

Contributor
Joined
May 10, 2016
Messages
179
1) If my replication task sends a snapshot of my primary system to a secondary remote backup system with a 'snapshot expiry' time set, then the data will be retained on the remote backup system even after the expiry time has passed?

Yes, snapshot expiration is a FreeNAS feature, not a ZFS feature - so snapshots on your remote system will not be destroyed (removed) unless commanded to by the FreeNAS replication script.

2) When using the 'Delete stale snapshots on remote system' option however the data is deleted from the remote system when the expiry time has passed or when the original data is deleted from the primary system?

Neither and both, they are deleted at the next replication after a snapshot on the source has been destroyed -doesn't matter if the auto snapshot script destroys the snapshot (since it expired), or you destroy a snapshot manually - from the GUI or shell.

The source systems "expired" snapshots are destroyed by the autosnap.py script in FreeNAS which is responsible for creating scheduled snapshots in FreeNAS. The replication script will destroy the remote snapshots that no longer exist on the source if that feature is enabled.

BTW, FWIW, since you have a two week snapshot lifetime - make sure that you don't neglect to verify that your replication is working within that time frame or you could find your source and targets no longer have a common snapshot for replication - which means the entire dataset will need to be sent. Courtesy of the school of hard knocks.
 

freenastier

Dabbler
Joined
Feb 9, 2017
Messages
20
Neither and both, they are deleted at the next replication after a snapshot on the source has been destroyed -doesn't matter if the auto snapshot script destroys the snapshot (since it expired), or you destroy a snapshot manually - from the GUI or shell.

The source systems "expired" snapshots are destroyed by the autosnap.py script in FreeNAS which is responsible for creating scheduled snapshots in FreeNAS. The replication script will destroy the remote snapshots that no longer exist on the source if that feature is enabled.

BTW, FWIW, since you have a two week snapshot lifetime - make sure that you don't neglect to verify that your replication is working within that time frame or you could find your source and targets no longer have a common snapshot for replication - which means the entire dataset will need to be sent. Courtesy of the school of hard knocks.

Thank you for the warning. I will increase the expiry time to prevent sending the entire data set from scratch due to unforeseen hick ups like a hardware malfunction of a power-down during a vacation of the resident where my remote backup machine will be placed.

So just to recapitulate to make sure I understood everything:
1) I have an automated task creating snapshots on my primary Freenas machine
2) The replication task on my primary machine uses these snapshot to synchronize the remote backup machine with the latest changes on my primary machines file system
3) The Freenas autosnap.py python script ensures the remote machine will mount the latest received snapshot, making the latest changes visible immediately on the remote file system
4) If an expiration time has been set for the snapshot then the autosnap.py pythonscript will the delete the expired snapshots
5) If the 'Delete stale snapshots on remote system' option has been set, then the autosnap.py python script will delete snapshots on the remote system if they don't exist on the primary system anymore

Then I have a follow up question:

What happens if a particular snapshot in between is deleted accidentally. For example there are 4 snapshots send to the remote machine and somehow snapshot 2 has been deleted. Does that break the chain and would that require sending snapshot 2, 3 and 4 again on the next replication update?
 

PhilipS

Contributor
Joined
May 10, 2016
Messages
179
3) The Freenas autosnap.py python script ensures the remote machine will mount the latest received snapshot, making the latest changes visible immediately on the remote file system

autosnap.py isn't involved in replication, autorepl.py is. The best I can tell, the only time mounting is involved is when the remote dataset is first created. During replication it stays mounted, and as soon as a zfs send is finished, the data is available.

4) If an expiration time has been set for the snapshot then the autosnap.py pythonscript will the delete the expired snapshots
Correct.
5) If the 'Delete stale snapshots on remote system' option has been set, then the autosnap.py python script will delete snapshots on the remote system if they don't exist on the primary system any more

Correct, except the autorepl.py script does this.

What happens if a particular snapshot in between is deleted accidentally. For example there are 4 snapshots send to the remote machine and somehow snapshot 2 has been deleted. Does that break the chain and would that require sending snapshot 2, 3 and 4 again on the next replication update?

The autorepl.py script finds the newest matching snapshots which is passed to zfs send, which will essentially send the delta between it and the next snapshot available on the sending host. I believe, if you delete an older snapshot on the receiving host, it will not be resent unless there are no newer snapshots on the receiving host. In your scenario, deleting snapshot 2 will not change what is sent on the next replication (the delta between snapshot 4 and 5).
 

freenastier

Dabbler
Joined
Feb 9, 2017
Messages
20
Thank you so much for your elaborate answers. They have been very helpfull in clearing up some of my misconceptions regarding ZFS and Freenas.

The autorepl.py script finds the newest matching snapshots which is passed to zfs send, which will essentially send the delta between it and the next snapshot available on the sending host. I believe, if you delete an older snapshot on the receiving host, it will not be resent unless there are no newer snapshots on the receiving host. In your scenario, deleting snapshot 2 will not change what is sent on the next replication (the delta between snapshot 4 and 5).
This makes sense. There are no concequences on the sending side.
It does however mean that the receiving host will no longer be able to rollback to snapshot 1, because snapshot 2 is missing right?
 

PhilipS

Contributor
Joined
May 10, 2016
Messages
179
It does however mean that the receiving host will no longer be able to rollback to snapshot 1, because snapshot 2 is missing right?

No, you will still be able to rollback to snapshot 1 on the receiving host.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
I understand that I can not store everything indefinitely, but I do not want to loose data either.

There is a script floating around which will prune snapshots, similar to apple's time machine backup strategy... keeping daily, then weekly, then monthly etc... with out having to have the snapshots be configured to auto-expire.

This could be a good alterntive on a replication target where you don't want the snapshots to simply expire.

...

<googling>

...

here ya go:
https://forums.freenas.org/index.ph...napshots-similar-to-apples-timemachine.10304/
 
Status
Not open for further replies.
Top