better check to input and resilvers
This commit is contained in:
@@ -27,6 +27,10 @@ while [ "$#" -gt 0 ]; do
|
||||
shift 2
|
||||
;;
|
||||
--label)
|
||||
if [ "$#" -lt 2 ] || [ -z "$2" ]; then
|
||||
echo "Error: --label requires a non-empty argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
opt_label="$2"
|
||||
shift 2
|
||||
;;
|
||||
@@ -42,6 +46,10 @@ while [ "$#" -gt 0 ]; do
|
||||
shift 2
|
||||
;;
|
||||
--prefix)
|
||||
if [ "$#" -lt 2 ] || [ -z "$2" ]; then
|
||||
echo "Error: --prefix requires a non-empty argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
opt_prefix="$2"
|
||||
shift 2
|
||||
;;
|
||||
@@ -60,11 +68,11 @@ done
|
||||
ZPOOL_STATUS=$(env LC_ALL=C zpool status 2>&1)
|
||||
|
||||
# Identify pools that should NOT receive snapshots:
|
||||
# - Pools currently running a scrub (to avoid additional I/O load).
|
||||
# - Pools currently running a scrub or resilver (to avoid additional I/O load).
|
||||
# - Pools in unhealthy states (anything other than ONLINE or DEGRADED).
|
||||
ZPOOLS_EXCLUDED=$(echo "$ZPOOL_STATUS" | awk -F ': ' '
|
||||
$1 ~ /^ *pool$/ { pool = $2 }
|
||||
$1 ~ /^ *scan$/ && $2 ~ /scrub in progress/ { print pool }
|
||||
$1 ~ /^ *scan$/ && $2 ~ /(scrub|resilver) in progress/ { print pool }
|
||||
$1 ~ /^ *state$/ && $2 !~ /ONLINE|DEGRADED/ { print pool }
|
||||
' | sort -u)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user