Skip to content

Commit

Permalink
feat: sanoid_check also verify no dataset has too many snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel authored and root committed Oct 14, 2024
1 parent b01b884 commit c39b644
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/zfs/sanoid_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ function check_last_snap_date {
fi
}

function check_num_snapshots {
# check if the number of snapshots is too much
# this would mean, we forgot to add a synchronized volume under sanoid control
local VOL_PATH=$1
local MAX_SNAPS=$2
local NUM_SNAP=$(zfs list -t snap -o name $VOL_PATH|wc -l)
if [[ $NUM_SNAP -gt $MAX_SNAPS ]]
then
ERRORS+=("Too many snapshots for $VOL_PATH ($NUM_SNAP)")
fi
}

function check_sanoid_run_date {
# check last sanoid service run time
local last_run_date=$(systemctl show sanoid.service --property=ExecMainExitTimestamp|cut -d "=" -f 2)
Expand All @@ -60,6 +72,7 @@ do
if [[ ! $EXCLUDED_DATASETS =~ :$volume: ]]
then
check_last_snap_date "$volume"
check_num_snapshots "$volume" 150
fi
done

Expand Down

0 comments on commit c39b644

Please sign in to comment.