yboetz / pyznap

ZFS snapshot tool written in python
GNU General Public License v3.0
197 stars 35 forks source link

Feature request: only take snapshots if files have been written #100

Open DragonQ opened 1 year ago

DragonQ commented 1 year ago

It'd be pretty cool to only have snapshots that actually are worth having. Seems fairly easy to implement based on this thread, e.g.

local WRITTEN=$(zfs get -H -o value written "${DATASET}")

if [ "${WRITTEN}" != "0" ]; then
  # take snapshot
fi
yboetz commented 1 year ago

Development on pyznap is pretty much on hold atm, I don't think I will have time to work on this in the near future. But I can keep it open if I ever get back to it.

svennd commented 1 year ago

This looks like a nice feature, it seems easily to implement so I took a stab at it. I think it takes much more work to get it in a nice production ready state. But as a POC :

https://github.com/yboetz/pyznap/compare/master...svennd:pyznap:master

I'm not a python person, just like this tool :)

xylle commented 1 year ago

This is not necessary for ZFS, no files writing : 0 octet in snapshot

svennd commented 1 year ago

I like this feature for the following use case : I keep allot of frequent and hourly snapshots. However I don't want my backup server to spin up every 15 minutes for no changes. Since half of the data I have is pretty much "stale" in terms of writting, this makes a lot of sense.

Also what is the point of having 100's of snapshots where 90% of them don't have any content even if the cost is near-zero.

xylle commented 1 year ago

If there's no snapshot, is it because there was no need or because there was an error? ZFS can handle a lot of snapshots, I've done them every 15 minutes for a year without any discomfort or slowdown. But if it's a real need ... For this type of content, why not change the frequency?

svennd commented 1 year ago

Cause we never know when change might happen and then I don't want to be stuck with a 7 day old snapshot.

You are saying you have 35.060 snapshots (per pool) -only for frequent- snapshots alone ? I do like to be able to verify manually everything is running fine now and again. But everyones his own, this was only a feature request I liked personally.

Either way, I doubt yboetz will take up this or any other feature given the time constrains the developer has previously mentioned.

xylle commented 1 year ago

So many snapshots is just for one pool, it doesn't make sense for the others, it's for files server in enterprise. But as an option, it doesn't hurt. It was just to give the information, ZFS is generally misunderstood. For me, it's more "kiss" to do always the same things.

yboetz commented 1 year ago

I agree with xylle, I'd rather keep it simple than have too many options that complicate the code. Also, following the reddit thread I think the reasoning mercenary_sysadmin gave to not have it in sanoid also makes sense.

In any case, pyznap is not in active development at the moment since I don't have time to work on it :/.