blob: 4d4dde91f5e305e17c61ee9e064d9479469a011e (
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
|
#!/bin/bash
. #ETCDIR#/backup.conf
export LC_ALL=C
for backupID in "${!backups[@]}"; do
[ -s "/tmp/${backupID}.pid" ] || continue
kill -0 $(cat "/tmp/${backupID}.pid") || continue
dir="${backups["${backupID}"]%% *}"
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
)
printf '%6.2f %% (%s%s %sB) %s\n' "${percentage}" "${size}" "${decimal}" "${unit}" "${backupID}"
done
|