Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add holding replication snapshots - #29 #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kapitainsky
Copy link
Contributor

@kapitainsky kapitainsky commented Apr 25, 2023

Without holding snapshots when destination dataset is missing (example can be external disk) script can accidentally delete last common snapshot - as can not compare source and destination.

The solution is to hold common snapshots using "zfs hold keep":

https://www.thegeekdiary.com/understanding-holding-a-zfs-snapshot-feature/

I have added required logic and did testing.

Without holding snapshots when destination dataset is missing (example can be external disk) script can accidentally delete last common snapshot - as can not compare source and destination.

The solution is to hold common snapshots using "zfs hold keep":

https://www.thegeekdiary.com/understanding-holding-a-zfs-snapshot-feature/
@kapitainsky
Copy link
Contributor Author

kapitainsky commented Apr 25, 2023

I tested with very aggressive snapshot retention policy and it works beautifully. When I remove destination dataset and keep creating new snapshots, pruning source dataset snapshots always preserves snapshot needed for future replication - it would be pruned otherwise breaking replication:

Deleting source snapshot: tank/iocage@zfsbud_20230425151851 <<--- on hold
Deleting source snapshot: tank/iocage@zfsbud_20230425151949
Deleting source snapshot: tank/iocage@zfsbud_20230425151951
Deleting source snapshot: tank/iocage@zfsbud_20230425151953
Deleting source snapshot: tank/iocage@zfsbud_20230425151955

When replication happens at some stage the hold is released (and new one is set on latest snapshots) and subsequent prunning gets rid of old snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant