Skip to content
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

--destroy-only keeps one snapshot less than specified #121

Open
loop-evgeny opened this issue Jan 20, 2021 · 3 comments
Open

--destroy-only keeps one snapshot less than specified #121

loop-evgeny opened this issue Jan 20, 2021 · 3 comments

Comments

@loop-evgeny
Copy link

When I run zfs-auto-snapshot --syslog --label=daily --keep=3 --destroy-only myzpool it keeps the last 2 snapshots, not 3.
Similarly zfs-auto-snapshot --syslog --label=daily --keep=2 --destroy-only myzpool it keeps the last 1 snapshot, not 2.

Ubuntu 18.04.5, installed zfs-auto-snapshot using apt install. I don't know what version of it I have - it doesn't report that and there is no --version.

@mschout
Copy link

mschout commented Feb 4, 2021

Same issue on Ubuntu 20.04.1 LTS

@mschout
Copy link

mschout commented Feb 4, 2021

Basically from a quick skim, I think it is because the "destroy" loop assumes that it just created a snapshot. One workaround is after reading the args, just decrement increment $opt_keep by one if --destroy-only was given.

@mschout
Copy link

mschout commented Feb 4, 2021

Something like this around line 350:

if [ -z "$opt_do_snapshots" -a ! -z "$opt_keep" ]
then
        opt_keep=$(( $opt_keep + 1 ))
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants