Comments (5)
@aaron-t Thanks for the bug report. I have tested this and this problem should be resolved with the latest release.
---Alex
from zfsnap.
I can't seem to find in the 2.0 or 1.11.1 where this fix would be. Can you point me in the right direction, just for my own learning purposes of how you got around this issue?
from zfsnap.
@aaron-t This fix happened quite awhile ago -- as part of the 2.0 rewrite. The fix came as part of an effort to make the code more robust so it could handle failures.
The code is in the RmZfsSnapshot() function in core.sh, but you'll note there is no code to specifically test for the holds and avoid them. Rather, zfsnap attempts to delete the snapshot and ZFS prevents it from doing so. The error is caught, printed in the console, and then the loop continues.
Since you said this was for your learning purposes, I took the liberty of looking at your patch and have a few general-purpose suggestions.
holds=$(`echo zfs holds -r $i | grep $i`)
Here, you're using both backticks () and the newer $() syntax. They both mean the same thing, and you only need to use one. zfsnap uses
because it is more portable to old shells, but $() is preferable because it allows nesting. Also the "echo" isn't needed. Lastly, the cost is high to call zfs holds
for each snapshot to be deleted. It'd be preferable to assemble a list of all holds of the dataset(s) zfsnap is operating on and then loop through that list as a check. The ZFS property "userrefs" is a counter of the number of holds on a given snapshot. zfs list -H -t snapshot -o name,userrefs
will provide that list.
if echo $holds | grep -q -e '@'; then
This is where I'd put the check for whether the snapshot to be deleted is in the pre-assembled list of holds. A function where the list is looped over, looking for $i would be much faster and more portable than calling grep. Using pipe spawns a subshell, which slows things down, and starting a grep process for each check would also be costly. Performance often isn't a concern with shell scripting, but when looping over 10,000+ snapshots, those performance decisions add up.
I hope that helped a bit. Let me know if you have any questions. :-)
---Alex
from zfsnap.
Thank you so much for taking the time to write this. My shell scripting ability is still in the read and modify stages so to get the values I needed I did some copy paste and echoed until it came out right.
I did understand that my placement was bad, but the goal was to modify your code as little as possible and keep it in one place so that I could still update when you released a new version. At some point I'll put in the 2.0 branch so I can use it stock and let you know if anything arises.
Thanks again for an awesome script, it's a 1/2 of my snapshot/replication for my zfsguru based storage system. In addition to zfsnap, I use a much more hacked zfsrep http://www.tediosity.com/zfs-replication-on-freebsd/ to send the snapshot to my other box. I only use its functions as a library really as it was easier than starting from scratch.
from zfsnap.
Hopefully for 2.1 we'll have a zfsnap send command as well (see #48). :-) And if you like using zfsrep as a library, you might want to checkout core.sh in zfsnap. One of the hidden features of the 2.0 rewrite is that we moved much of the logic into functions all in a single library. And they come with unit tests, so they should be reliable. It can be quite useful for your own custom scripts.
---Alex
from zfsnap.
Related Issues (20)
- FATAL: trying to delete zfs pool or filesystem? WTF?
- redirection to stderr prevents use in systemd-services HOT 6
- Recursive snapshot without parent directory
- Is this still an active project? HOT 3
- Delete any snapshots that have expired? HOT 3
- Free predefined amount of space by removing snapshots
- Possibility to use inotify to trigger snapshots HOT 4
- Argument list too long while deleting old snapshots
- Possibly relying on createtxg and guid properties HOT 4
- smb.conf for zfsnap HOT 1
- Request: Add support for a pre- and post-script HOT 4
- How do I use zfsnap to backup snapshots of one pool to another? HOT 2
- daily snapshots generated, which I never set up HOT 4
- How to use xPERIODICx scripts? HOT 1
- Wanted: new maintainer HOT 7
- zfSnap -d command is not working HOT 2
- zfsnap_delete periodic script needs filesystem arguments
- Make prefixes not need - at the end HOT 3
- Minor error in manpage HOT 4
- zfsnap destroy doesn't delete snapshots HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zfsnap.