Periodic Snapshots Cull Script

Status
Not open for further replies.

irTwit

Dabbler
Joined
Aug 18, 2014
Messages
48
I created a script to reduce the number of snapshots shown in the Window's folder "Previous Versions" tab as they get older.

The script reduces the number snapshots created by FreeNAS Periodic Snapshots Tasks. It uses two methods, first it compares snapshots two at a time deleting newer snapshots that have no difference from the older one. Second, after a user specified time it reduces the number of snapshots taken throughout a day to one per day, then after another user defined length of time reduces the number to one per week.

https://github.com/WolfBungalow/FreeNAS-Cull-Snapshots

I saw fracia's ZFS Rollup script but it was over my head and I learn best when trying to make something.

Disclaimer
I'm a noob. Use at your own risk. Feedback appreciated.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
If you set your snapshots up correctly I fail to see how this script would be useful.
 

irTwit

Dabbler
Joined
Aug 18, 2014
Messages
48
If you set your snapshots up correctly I fail to see how this script would be useful.

I would love a built-in option, and I would setup three tasks, but I want access to the snapshots through the Windows Previous Version feature. To set that up requires me to select a snapshot task under the FreeNAS SMB share but as far as I can tell you can only select one task, not three.

With the script all the snapshots for the dataset are available. Additionally, each is unique because the snapshots that held no difference from the ones preceding it are deleted. This makes easier finding the changed files instead of clicking through duplicate snapshots.

upload_2017-7-2_1-38-54.png
 

HateTheDrake

Dabbler
Joined
Jun 23, 2017
Messages
13
If you set your snapshots up correctly I fail to see how this script would be useful.

Agreed.

I'm a noob here, though I was under the impression that it would auto-prune the snaps if you set them up correctly. I have several setup, though do not have enough snaps to verify their removal.

Mine are:
every 2 hours w/in business hours, keep for two weeks.
every week, keep for a month.
every month, keep for a year.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
You should see messages scrolling in your footer console when the snapshots are pruned.

snap.jpg
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
I would love a built-in option, and I would setup three tasks, but I want access to the snapshots through the Windows Previous Version feature. To set that up requires me to select a snapshot task under the FreeNAS SMB share but as far as I can tell you can only select one task, not three.
That's going to change soon-ish.
 

frankvh

Dabbler
Joined
Sep 7, 2015
Messages
10
Sorry to revive an older thread. This script looks great. One question. I looked at the python and I'm no expert so the question: In the cullIdenticalSnaps subroutine, is there any possibility this would delete the most recent snapshot? If, for example, the most recent, and the next-most-recent, were both empty?

I just want to be confident the most recent snapshot will never be deleted, no matter what.

Thanks!
 

toolforger

Explorer
Joined
Aug 8, 2017
Messages
60
I just want to be confident the most recent snapshot will never be deleted, no matter what.

Deleting the older snapshot means: I lose the information about which date the snapshot had. Not sure how to recover this easily, but if I really need that information I guess I could hack something together with find, ls -t, sort, and head -n 1.
Deleting the newer snapshot means: I lose the information about when the snapshot was last run. This information should be in the syslog.
Given that I assume that

Now that's my use case. What is your use case that makes you want to keep the newer snapshot?
 
Status
Not open for further replies.
Top