diff options
Diffstat (limited to 'bareos/check-if-bareos-backup-is-running')
-rwxr-xr-x | bareos/check-if-bareos-backup-is-running | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/bareos/check-if-bareos-backup-is-running b/bareos/check-if-bareos-backup-is-running index e638869df..ea7cc3aff 100755 --- a/bareos/check-if-bareos-backup-is-running +++ b/bareos/check-if-bareos-backup-is-running @@ -5,46 +5,11 @@ if [ $# -ne 0 ]; then 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 +if awk '{print $3}' /proc/net/tcp \ +| cut -d: -f2 \ +| grep -qxiF '238F'; then + >&2 echo 'bareos-fd is not connected to bareos-sd' +else + >&2 echo 'bareos-fd is connected to bareos-sd' + exit 1 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' |