diff options
author | Erich Eckner <git@eckner.net> | 2019-05-03 22:05:58 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-05-03 22:05:58 +0200 |
commit | bc1d178edbe7c7b74a644d0fbe14e0fc0f5bf83c (patch) | |
tree | 5a7da7dddfbc46ede2d89339c83a014e61bc0b80 | |
parent | c265f32c00bac539b42e92a34c5a5d01eafea2d1 (diff) | |
download | hardlinkedBackups-bc1d178edbe7c7b74a644d0fbe14e0fc0f5bf83c.tar.xz |
backup-progress: show current size, too
-rwxr-xr-x | backup-progress.in | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/backup-progress.in b/backup-progress.in index c5cb655..61f8c1e 100755 --- a/backup-progress.in +++ b/backup-progress.in @@ -15,16 +15,23 @@ for backupID in "${!backups[@]}"; do | tail -n1 ) last_size=$( - du -s "${dir}/${last}" \ + du -sb "${dir}/${last}" \ | awk '{print $1}' ) current_size=$( - du -s "${dir}/aktuell" \ + du -sb "${dir}/aktuell" \ | awk '{print $1}' ) + size="${current_size}" + for unit in '' k M G T P Y; do + if [ "${size}" -lt 1024 ]; then + break + fi + size=$((size/1024)) + done percentage=$( printf '100*%s/%s\n' "${current_size}" "${last_size}" \ | bc -l ) - printf '%6.2f %% %s\n' "${percentage}" "${backupID}" + printf '%6.2f %% (%s %sB) %s\n' "${percentage}" "${size}" "${unit}" "${backupID}" done |