]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add: function sizeHumanReadable
authorBastian Dehn <hhaalo@arcor.de>
Thu, 9 Aug 2018 16:17:29 +0000 (18:17 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 9 Aug 2018 16:31:17 +0000 (18:31 +0200)
backup

diff --git a/backup b/backup
index e58ab040689b3907c47ba03616f1bdf25b439e17..2c6e7ca9427f7a198cf922a0d0910b8f6f2ca2fc 100755 (executable)
--- 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