From 7004f916117ce295c8fd8a92bd5a0cc9a0436891 Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Tue, 28 Jul 2020 17:10:35 +0200 Subject: [PATCH] added progress output --- zfs-inplace-rebalancing.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zfs-inplace-rebalancing.sh b/zfs-inplace-rebalancing.sh index 0ec4cc1..91ba92f 100755 --- a/zfs-inplace-rebalancing.sh +++ b/zfs-inplace-rebalancing.sh @@ -5,9 +5,15 @@ set -e # exit on undeclared variable set -u +current_index=0 + function rebalance () { file_path=$1 + current_index="$((current_index + 1))" + progress_percent=$(echo "scale=2; $current_index*100/$file_count" | bc) + echo "Progress -- Files: $current_index/$file_count ($progress_percent%)" + tmp_extension=".balance" echo "Copying '${file_path}' to '${file_path}${tmp_extension}'..." @@ -51,6 +57,11 @@ function rebalance () { } root_path=$1 + +# count files +file_count=$(find "$root_path" -type f | wc -l) +echo "Files to rebalance: $file_count" + # recursively scan through files and execute "rebalance" procedure find "$root_path" -type f -print0 | while IFS= read -r -d '' file; do rebalance "$file"; done echo ""