librelist archives

« back to archive

Shell Patterns for `zfsnap destroy` prefixes

Shell Patterns for `zfsnap destroy` prefixes

From:
Alex Waite
Date:
2014-04-22 @ 11:42
I've been kicking around the idea that it might be a nice feature for 
`zfsnap destroy -p` accept shell patterns.

Currently the following ignores all snapshots with a prefix:
     zfsnap destroy -rnvD pool/fs

To be clear, I consider this behavior to be a feature. But consider the 
following scenario:

To delete /all zfsnap snapshots/ for a particular fs, one would have to 
manually compile a list of all prefixes in use and pass them to -p:
     zfsnap destroy -rnvD -p 'hourly- daily- etc-' pool/fs -P pool/fs

zfsnap has no way of listing all prefixes in use by a given pool/fs, so 
building the above list would have to be done manually or with some 
grep-foo.

With shell patterns, it's a bit easier

Destroy all zfsnap snapshots with a prefix
     zfsnap -rnvD -p "?*" pool/fs

Destroy all zfsnap snapshots (with or without a prefix)
     zfsnap -rnvD -p "*" pool/fs

Obviously it wouldn't be limited to wildcards. The pattern would be 
handled natively by the shell, so the patterns can be quite expressive.

I think this feature could be quite powerful, but I also think it has 
great capacity to cause damage if used incorrectly.

I havn't looked into how much this would change, but care would have to 
be taken to make sure the user supplied pattern doesn't alter the 
patterns used by zfsnap internally.

This /might/ result in a syntax change with the way prefixes are defined 
(especially handling -p being used multiple times). Thus, if this is 
going to happen, it should probably happen for the 2.0.0 release.

My question is whether this feature would be useful in real world 
scenarios beyond ones described above?

I'm not thrilled with the idea of adding another feature to the 2.0 
release. And it will require a lot of testing to make sure it's behaving 
as intended. But, I think this could be a very nice feature.

Any thoughts?

---Alex

Re: [zfsnap] Shell Patterns for `zfsnap destroy` prefixes

From:
Aldis Berjoza
Date:
2014-04-22 @ 13:39
<div> </div><div> </div><div>22.04.2014, 15:00, "Alex Waite" 
<alexqw85@gmail.com>:</div><blockquote type="cite"><p>I've been 
kicking around the idea that it might be a nice feature for <br />`zfsnap 
destroy -p` accept shell patterns.<br /><br />Currently the following 
ignores all snapshots with a prefix:<br />     zfsnap destroy -rnvD 
pool/fs<br /><br />To be clear, I consider this behavior to be a feature. 
But consider the <br />following scenario:<br /><br />To delete /all 
zfsnap snapshots/ for a particular fs, one would have to <br />manually 
compile a list of all prefixes in use and pass them to -p:<br 
/>     zfsnap destroy -rnvD -p 'hourly- daily- etc-' pool/fs -P pool/fs<br
/><br />zfsnap has no way of listing all prefixes in use by a given 
pool/fs, so <br />building the above list would have to be done manually 
or with some <br />grep-foo.<br /><br />With shell patterns, it's a bit 
easier<br /><br />Destroy all zfsnap snapshots with a prefix<br 
/>     zfsnap -rnvD -p "?*" pool/fs<br /><br />Destroy all zfsnap 
snapshots (with or without a prefix)<br />     zfsnap -rnvD -p "*" 
pool/fs<br /><br />Obviously it wouldn't be limited to wildcards. The 
pattern would be <br />handled natively by the shell, so the patterns can 
be quite expressive.<br /><br />I think this feature could be quite 
powerful, but I also think it has <br />great capacity to cause damage if 
used incorrectly.<br /><br />I havn't looked into how much this would 
change, but care would have to <br />be taken to make sure the user 
supplied pattern doesn't alter the <br />patterns used by zfsnap 
internally.<br /><br />This /might/ result in a syntax change with the way
prefixes are defined <br />(especially handling -p being used multiple 
times). Thus, if this is <br />going to happen, it should probably happen 
for the 2.0.0 release.<br /><br />My question is whether this feature 
would be useful in real world <br />scenarios beyond ones described 
above?<br /><br />I'm not thrilled with the idea of adding another feature
to the 2.0 <br />release. And it will require a lot of testing to make 
sure it's behaving <br />as intended. But, I think this could be a very 
nice feature.<br /><br />Any thoughts?<br /><br />---Alex<br /><br 
/></p></blockquote><div> </div><div>I think we should avoid this 
feature.</div><div>I also don't see much benefits of having 
it.</div><div> </div><div>Ok, for example user is using 20 prefixes. So 
what?</div><div>sh was invented to make it possible to extend 
functionality of sh.</div><div>So if I was the unlucky user that needs to 
delete snapshots with 20 prefixes, I would write wrapper 
script.</div><div> </div><div>I think user supplied patterns is zfsnap 
would be too dangerous to justify development/testing of this 
feature.</div><div> </div><div>-- <br />Aldis Berjoza<br />FreeBSD 
addict</div><div> </div>

Re: Shell Patterns for `zfsnap destroy` prefixes

From:
Alex Waite
Date:
2014-04-22 @ 14:14
On 04/22/2014 03:39 PM, Aldis Berjoza wrote:
> [snip html formatting]
 > I think we should avoid this feature.
 > I also don't see much benefits of having it.
 > Ok, for example user is using 20 prefixes. So what?
 > sh was invented to make it possible to extend functionality of sh.
 > So if I was the unlucky user that needs to delete snapshots with 20 
prefixes, I would write wrapper script.

That is a good point, and it is easily done when using core.sh; it makes 
site-specific scripts easy to program.

 > I think user supplied patterns is zfsnap would be too dangerous to 
justify development/testing of this feature.

I agree about the danger. The more I think about it, the risk/benefit 
ratio currently does not merit the addition of this feature.

Furthermore, 2.0 is looking pretty good, and should be ready for a 
release in the next few weeks --- after it been tested on a few more 
OSs. Adding something this risky surely won't help that effort.

---Alex