From 0d7a8e667b95e9dd7cee23883068a1a762c9ef08 Mon Sep 17 00:00:00 2001 From: hjp Date: Sat, 28 Sep 2019 09:17:55 +0000 Subject: [PATCH] Report free space on all found backup volumes and the total --- scripts/backup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index 0550bc0..8fcca32 100755 --- a/scripts/backup +++ b/scripts/backup @@ -71,19 +71,21 @@ my @backup_dirs = map { my $avg_file_size = $bavail * ($blocks - $bfree) / ($files - $ffree); my $available_bytes_by_files = $avg_file_size * $favail; $available_bytes = $available_bytes_by_files if $available_bytes_by_files < $available_bytes; + $ca->log(3, "found base $_ (est. $available_bytes bytes)"); [ $_, $available_bytes ] } glob("/backup/*/active"); my $sum_free = 0; $sum_free += $_->[1] for (@backup_dirs); +$ca->log(3, "total free est. $sum_free bytes"); my $rnd = rand() * $sum_free; my $count_free = 0; my $backup_dir; for(@backup_dirs) { $count_free += $_->[1]; - $ca->log(3, "considering base $_->[0] (est. $_->[1] bytes)\n"); + $ca->log(3, "considering base $_->[0] (est. $_->[1] bytes)"); if ($count_free >= $rnd) { $backup_dir = $_->[0]; - $ca->log(3, "using base $_->[0]\n"); + $ca->log(3, "using base $_->[0]"); last; } }