Check all pipe components in db-dump.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Fri, 15 Mar 2019 11:34:33 +0000 (12:34 +0100)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Fri, 15 Mar 2019 11:34:33 +0000 (12:34 +0100)
db-dump

diff --git a/db-dump b/db-dump
index 5da3811..f4d795e 100755 (executable)
--- a/db-dump
+++ b/db-dump
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash
 DUMP_DIR=/var/backups/bacula-cn
 CONFIG=/etc/default/bacula-cn
 
@@ -32,6 +32,7 @@ then
     MYSQL_DUMP="$DUMP_DIR/mysql.dump.gz"
     MYSQL_OPT="--defaults-extra-file=/etc/mysql/debian.cnf --all-databases"
 
+    set -o pipefail
     if mysqldump $MYSQL_OPT | gzip > $MYSQL_DUMP; then
         touch $MYSQL_EXCLUDE
     fi
@@ -43,6 +44,7 @@ if [ -d /var/lib/postgresql \
 then
     PG_DUMP="$DUMP_DIR/postgresql.dump.gz"
 
+    set -o pipefail
     if su postgres -c pg_dumpall | gzip > $PG_DUMP; then
         touch $PG_EXCLUDE
     fi