I do have a freenas server as backup server - every evening it creates a snapshot of a dataset and some minutes lates an rsync task starts to backup the data to my freenas.

In the webui I only have the option to auto-create snapshots and auto-delete them after a specific time.

Does anyone has a script to thin snapshots out? I only want to have a daily snapshot of the last week, a weekly of the last 6 weeks and a monthly for 2 months before that 6 weeks...

(The data is volatile, so thinning out snapshots would preserve some space.)


You can use a script written by fracai on the Freenas forums. The script is hosted on github, it's called zfs-rollup. You only need the rollup.py file. Links at the end.

I've used it for years and it works very well. You specify a few parameters on the comandline, 1) the prefix (filter) for the snapshot names it should look to delete, 2) the Dataset you want it to look under (it will recurse), and 3) the intervals for each that you want to keep.

The below example will remove snapshots prefixed with 'auto', under the BACKUP/nas dataset, that do not meet 7 daily, 4 weekly, and 3 monthly timeframes.

rollup.py -i daily:7,weekly:4,monthly:3 -p auto -r BACKUP/nas

You can cron that up in the Freenas GUI without issue. I personally specify different cron jobs for different datasets so I can keep a varying amounts of backups based on my data types.

Freenas forum/resource describing the scripts intent


Github source for the script


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.