zectl icon indicating copy to clipboard operation
zectl copied to clipboard

Feature request : prune subcommand

Open eoli3n opened this issue 4 years ago • 4 comments

I started to work on a pacman hook and his prune script.

https://github.com/eoli3n/zectl-pacman-hook

I get into some little problems which could be fixed by some zectl query arguments. Would you check TOFIX lines and tell me what's possible or not ? (It's not usable as is, just a POC to show the idea). https://github.com/eoli3n/zectl-pacman-hook/blob/master/zectl-prune.sh#L4

Maybe you should consider managing prune subcommand in zectl ? Something like borg prune would be great : https://github.com/eoli3n/dotfiles/blob/wayland/roles/borgbackup/files/backup#L34

See you.

eoli3n avatar May 09 '20 15:05 eoli3n

I'll definitely think about it, I don't want to add too much extra code that isn't core to the tool, so I'm hesitant to add extra commands, but I will consider it. I do think it would be possible to get the functionality you looking for with your script.

Reviewing your TOFIXes I have some questions/feedback.


L4

TOFIX: 'zectl' needs an 'unset' subcommand

Are you just looking to "erase" a property?

be_active_ds="$(zpool get bootfs -H -o value)"
be_root="${be_active_ds%/*}"
zfs inherit org.zectl:yourprop "${be_root}"

L24

TOFIX: 'zectl get -H nonexistantkey' should print an error and exit 1

Can you work with just having the property empty -? I'm trying to follow zfs get as closely as possible, and that is the behaviour it uses for a non-existent user property.

L47

TOFIX: 'zectl list' needs a positionnal arg to filter/query 'ACTIVE|BOOTED|NONE' envs

I would rather not add a argument just to remove non N/R/RN environments.

L52

TOFIX: 'zectl list' needs a positionnal arg to order by date

This, I would like to just do by default. If you'd like to open an issue for a feature request to remind me, I will put it on my list. I'm not promising any time frame though. We also take PRs :relaxed:

johnramsden avatar May 10 '20 01:05 johnramsden

Are you just looking to "erase" a property?

Thanks it worked.

❯ zfs get all zroot/ROOT | grep zectl
zroot/ROOT  org.zectl:pacmanhook             yes                              local
zroot/ROOT  org.zectl:bootloader             systemdboot                      local
zroot/ROOT  org.zectl:org.zectl.pacmanhook   yes                              local
zroot/ROOT  org.zectl:pacmanhook-prunecount  5                                local

~
❯ sudo zfs inherit -r org.zectl:org.zectl.pacmanhook zroot/ROOT

~
❯ zfs get all zroot/ROOT | grep zectl
zroot/ROOT  org.zectl:pacmanhook             yes                              local
zroot/ROOT  org.zectl:bootloader             systemdboot                      local
zroot/ROOT  org.zectl:pacmanhook-prunecount  5  

Can you work with just having the property empty -?

I do with this -> https://github.com/eoli3n/zectl-pacman-hook/blob/e654483d2d461c0407990ff7b15607cc08bb5746/zectl-prune.sh#L31

I'm trying to follow zfs get as closely as possible

I agree with this.

I would rather not add a argument just to remove non N/R/RN environments.

So let's keep piping into grep -Ev '\ N\ |\ NR\ |\ R\ ' : https://github.com/eoli3n/zectl-pacman-hook/blob/e654483d2d461c0407990ff7b15607cc08bb5746/zectl-prune.sh#L48

We also take PRs

I would like to, but i'm not a C dev :)

Let's rename that issue. Thanks for your answer !

eoli3n avatar May 10 '20 09:05 eoli3n

About the prune subcommand, i think that i would be a useful feature. Creating snapshots is a thing, but it's more powerful when automated, and it's harder to manage snapshots rotation well without a prune function.

Here's a good base of what it could be : https://borgbackup.readthedocs.io/en/stable/usage/prune.html

eoli3n avatar May 10 '20 10:05 eoli3n

AUR hook package in online ;) https://aur.archlinux.org/packages/zectl-pacman-hook/

eoli3n avatar May 11 '20 10:05 eoli3n