From: Bastian Dehn Date: Thu, 9 Aug 2018 16:17:29 +0000 (+0200) Subject: add: function sizeHumanReadable X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=a7d0acd75b6726e7aa81047175058df6654ef2ba;p=simple-backup.git add: function sizeHumanReadable --- diff --git a/backup b/backup index e58ab04..2c6e7ca 100755 --- a/backup +++ b/backup @@ -25,6 +25,20 @@ ReadArguments() fi } +SizeHumanReadable() +{ + local size=$1 + local einheit=("Bytes" "KiB" "MiB" "GiB" "TiB" "PiB") + local count=0 + + while [ $size -gt 1024 ]; do + size=$((size / 1024)) + ((count++)) + done + + printf "%s %s\n" "$size" "${einheit[$count]}" +} + CreateBackupFolder() { local dayAnzahl=1 @@ -82,8 +96,9 @@ BackupTypOfVMDisc() | head --lines=1 | awk \ --field-separator="," '{print $2}' \ | sed 's/[ \| Bbytes]//g') + local readonly humanSize=$(SizeHumanReadable "$DiskSize") - printf "DiskSize: %s\n\n" "$DiskSize" + printf "DiskSize: %s\n\n" "$humanSize" ssh $remoteLogin "dd bs=1M if=$Disk | gzip --stdout" \ | pv --rate --bytes \ | dd of=$backRemotePCPath/$DiskName.gz