-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feature request: add new option to zfs snapshot
subcommand to skip creation of zero sized snapshots
#6041
Comments
because all existing snapshotting tools fail to be able to skip creation of zero sized snapshots and none are planning to do so :( |
While I see the reasoning, I'm going to need an override. If you're trying to use Please don't silently not do what the user expects to happen. |
I fail to see how this optional feature would affect existing workflows. |
but the users expects that to happen! when the user explicitly asks for -z parameter, the user expects that zero sized snapshots are not created. when the user does not ask for -z parameter, the snapshot is created and that is what the user is expecting. |
Ugh, I missed the part where it's a -z parameter. I thought it was presented as being the new default behaviour. Sorry, it's been one of those mornings. |
While the created snapshots can be culled afterwards in case they're 'empty' (compared to the last one) this takes way longer (and also bloats zpool history) compared to be able to not take them at all. And even when the functionality can be scripted (as mentioned) I suppose a -z option would have a way better runtime. So for me this would be a very good improvement as it would massively cut down the amount of redundant snapshots, at least on most of the systems I maintain, so I could retire the script (and the related overhead) that currently has to remove them. |
This can now be achieved using ZFS Channel Programs ( |
i tried reading about zcp but i find it very hard to understand what it really does and how can it help for this issue. |
The following ZCP script was briefly tested on a throwaway VM, feel free to adapt it to your environment: arg = ...
argv = arg["argv"]
root = argv[1]
name = argv[2]
function snapshot_r(root, name)
for child in zfs.list.children(root) do
snapshot_r(child, name)
end
if (zfs.get_prop(root , "written") > 0) then
zfs.sync.snapshot(root .. "@" .. name)
end
end
snapshot_r(root, name) Test output (snapshot is taken only the first time because
|
What is the exact meaning of
from https://illumos.org/man/1M/zfs-program ? In case I understand it correnctly: Having -z as an option to the normal zfs snapshot command would allow users to execute it (if zfs allow'ed) - while the channel program workaround is limited to root... ? |
@GregorKopka exactly. |
hm, so what is the effort difference between above and the following code in a modified zfs-auto-snapshot script? the end user still has to verify if the written property is non-zero. so what's the benefit of zfs program vs the already working modified zfs-auto-snapshot?
my issue was request about simplifying the user effort with a zfs command with a new parameter... that would be very simple for the end user... the recommened approach is no less difficult than the code path in zfs-auto-snapshot... |
@loli10K then the channel programs approach dosn't solve it as it dosn't support delegation to normal users (which the original request would). While technically impressive it dosn't help a normal user. The workaround with pruning a zfs list to create a zfs snapshot command line in userland (plenty of parsing in both directions) seems to be way more costly, plus I suspect there are limits on the length of the command line of a Thus I support it as a flag, or through root being able to prepare channel programs that can then be called by normal users (with at least checking their allow'ed abilities vs. the sub-operations taken by the channel progam). A flag would be more practical, imho. |
From
The bold part is the important one. From my perspective As a side now, keep in mind this option would probably prevent sending snapshots with the |
@kpande Could you please elaborate why this was closed? |
@kpande Unless I missed the ZoL release that enabled running ZCP without root privileges: please reopen. |
Might be a separate issue, but without being able to delegate to non-root users this isn't solved. |
Let's have this scenario
I would like to have a new option, let's call it
-z
for this example, that when used would produce the new situation:Basically what I'd like to be able to ask 'zfs snapshot' when
-z
parameter is present is:"before you create a snapshot, regardless if is requested recursively or not, check if any previous snapshot exists and if it does then check if the newly to-be-created snapshot would reference any data that the previous snapshot doesn't .
if it doesn't reference new data since previous snapshot, silently skip creation of the requested snapshot and report a successful operation"
The text was updated successfully, but these errors were encountered: