blob: 90492fb2c0738440b9ebf1549662aeadc7e42b97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/bash
. #ETCDIR#/backup.conf
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\}' \
| sort \
| tail -n1
)
last_size=$(
du -sb "${dir}/${last}" \
| awk '{print $1}'
)
current_size=$(
du -sb "${dir}/aktuell" \
| awk '{print $1}'
)
size="${current_size}"
decimal=''
for unit in '' k M G T P Y; do
if [ "${size}" -lt 1024 ]; then
break
fi
decimal=".$(((size%1024*10)/1024))"
size=$((size/1024))
done
percentage=$(
printf '100*%s/%s\n' "${current_size}" "${last_size}" \
| bc -l
)
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
|