Ensure to keep a number of snapshots after matching a prefix or suffix
This commit is contained in:
parent
fe7ca9e6ee
commit
f22f85ed9a
|
@ -284,16 +284,6 @@ lines=()
|
|||
while read -r line; do
|
||||
read -r creation used snapshot <<< "$line"
|
||||
|
||||
fsname=${snapshot%@*}
|
||||
if [[ $keep -gt 0 ]]; then
|
||||
|
||||
if (( ${kept_arr["$fsname"]:-0} < keep )); then
|
||||
((kept_arr[$fsname]++))
|
||||
debug "skipping $snapshot: kept ${kept_arr["$fsname"]}/$keep"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# ensure optional prefix matches
|
||||
snapname=${snapshot#*@}
|
||||
if [[ -n $prefix ]]; then
|
||||
|
@ -331,6 +321,17 @@ while read -r line; do
|
|||
fi
|
||||
fi
|
||||
|
||||
# ensure at least keep snapshots are kept for each fsname
|
||||
fsname=${snapshot%@*}
|
||||
if [[ $keep -gt 0 ]]; then
|
||||
|
||||
if (( ${kept_arr["$fsname"]:-0} < keep )); then
|
||||
((kept_arr[$fsname]++))
|
||||
debug "skipping $snapshot: kept ${kept_arr["$fsname"]}/$keep"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# ensure snapshot is older than the cutoff time
|
||||
delta=$((now - creation))
|
||||
ht=$(human-time "$delta")
|
||||
|
|
Loading…
Reference in New Issue