summaryrefslogtreecommitdiff
path: root/backup-progress.in
blob: c5cb65586a6dabc530ff6812492859df6bc236fa (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
#!/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 -s "${dir}/${last}" \
      | awk '{print $1}'
  )
  current_size=$(
    du -s "${dir}/aktuell" \
      | awk '{print $1}'
  )
  percentage=$(
    printf '100*%s/%s\n' "${current_size}" "${last_size}" \
      | bc -l
  )
  printf '%6.2f %%  %s\n' "${percentage}" "${backupID}"
done