blob: e638869df5caa061b6843ede60fe3e4b3866813a (
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
|
#!/bin/bash
if [ $# -ne 0 ]; then
>&2 echo 'check-if-bareos-backup-is-running: too many arguments'
exit 2
fi
bareos_pid=$(
pgrep -xf '(.*/)?bareos-fd' \
| head -n1
)
if [ -z "${bareos_pid}" ]; then
>&2 echo 'check-if-bareos-backup-is-running: cannot find running bareos-fd'
exit 2
fi
if ! grep -qxF bareos-fd "/proc/${bareos_pid}/comm"; then
>&2 echo 'check-if-bareos-backup-is-running: cannot find running bareos-fd'
exit 2
fi
if [ $(whoami) != 'root' ]; then
>&2 echo 'check-if-bareos-backup-is-running: must be run as root'
exit 2
fi
time_out=$((
$(date +%s)+30
))
was=$(
sed '
s/^read_bytes: //
t
d
' "/proc/${bareos_pid}/io"
)
while [ $(date +%s) -le ${time_out} ]; do
sleep 1
if sed '
s/^read_bytes: //
t
d
' "/proc/${bareos_pid}/io" \
| grep -qvxF "${was}"; then
>&2 echo 'bareos-fd is reading'
exit 1
fi
done
>&2 echo 'bareos-fd is not reading'
|