summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-09-04 12:21:54 +0200
committerErich Eckner <git@eckner.net>2019-09-04 12:21:54 +0200
commit0ac8bd369c3247b0687c0bdd20f8275d5c545022 (patch)
tree0b73b8a37bde6d8022b4807ef2c22cfc8bc6c51b
parenta2476325c636ebabae2413981b258718f874a79a (diff)
downloadhardlinkedBackups-0ac8bd369c3247b0687c0bdd20f8275d5c545022.tar.xz
backup-progress: use same names as last-backups, reorder and -justify output
-rwxr-xr-xbackup-progress.in49
1 files changed, 48 insertions, 1 deletions
diff --git a/backup-progress.in b/backup-progress.in
index 4d4dde9..90492fb 100755
--- a/backup-progress.in
+++ b/backup-progress.in
@@ -4,10 +4,21 @@
export LC_ALL=C
+declare -A nm
+declare -A pc
+declare -A sz
+
for backupID in "${!backups[@]}"; do
[ -s "/tmp/${backupID}.pid" ] || continue
kill -0 $(cat "/tmp/${backupID}.pid") || continue
dir="${backups["${backupID}"]%% *}"
+ dir="${dir%/}"
+ nm[${#nm[@]}]=$(
+ echo ${dir} \
+ | sed "s#/\(${recognSubdirRegex}\)\$#_\1#" \
+ | sed "s#/rsync\$##; s#/duplicity\$##" \
+ | sed 's#^.*/##'
+ )
last=$(
ls -1 "$dir" \
| grep '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}' \
@@ -35,5 +46,41 @@ for backupID in "${!backups[@]}"; do
printf '100*%s/%s\n' "${current_size}" "${last_size}" \
| bc -l
)
- printf '%6.2f %% (%s%s %sB) %s\n' "${percentage}" "${size}" "${decimal}" "${unit}" "${backupID}"
+ pc[${#pc[@]}]=$(
+ printf '%6.2f %%' "${percentage}"
+ )
+ sz[${#sz[@]}]=$(
+ printf '(%s%s %sB)' "${size}" "${decimal}" "${unit}"
+ )
+done
+
+nm_len=$(
+ for n in "${nm[@]}"; do
+ printf '%s\n' "${#n}"
+ done \
+ | sort -n \
+ | tail -n1
+)
+
+pc_len=$(
+ for p in "${pc[@]}"; do
+ printf '%s\n' "${#p}"
+ done \
+ | sort -n \
+ | tail -n1
+)
+
+sz_len=$(
+ for s in "${sz[@]}"; do
+ printf '%s\n' "${#s}"
+ done \
+ | sort -n \
+ | tail -n1
+)
+
+for i in "${!nm[@]}"; do
+ printf '%-'"${nm_len}"'s %'"${pc_len}"'s %'"${sz_len}"'s\n' \
+ "${nm[${i}]}" \
+ "${pc[${i}]}" \
+ "${sz[${i}]}"
done