PULL Replication Task Issues

Joined
Aug 30, 2023
Messages
22
My Pull task is working. But i dont want to delete snapshots based on time. For the source system i dont mind but on the destination i want to delete snapshots based on the number of snapshots. As example i only want to keep the last 3 snapshots on backup server. That way if the pull fails for whatever reason they are not deleted after 2 days like the source. On the source it keeps snapshots for 2 days this is fine because it runs every day. But for the Pull on destination server i want it to pull everyday but keep the last three snapshots not follow source and use time based. Any ideas? Why isnt there an option that says keep last amount of snapshots?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You could write a shell script executed by cron that does that.
 
Joined
Aug 30, 2023
Messages
22
Can you give me a hint on that. Also if I do that do I just set retention policy in replication to none since I'm letting cron Handle deletion
 
Joined
Aug 30, 2023
Messages
22
I figured it out for anyone needing the cron job command here it is....

zfs list -H -o name -t snapshot | grep <dataset_name>@ | sort -r | awk 'NR>3' | xargs -n 1 zfs destroy -r

Just replace the <dataset_name> with the path of your dataset.
 
Top