aboutsummaryrefslogtreecommitdiff
path: root/handlers/mysql.in
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-01-08 23:40:23 +0100
committerintrigeri <intrigeri@boum.org>2010-01-08 23:40:23 +0100
commit47313bca65de105145f2168538b294a9bcc0e98d (patch)
tree8fcc10551cae627e432cb9366608cf2c935817e0 /handlers/mysql.in
parent49bfd02bd3ee6eccc2eaa0a7c668c46b4a15af0a (diff)
downloadbackupninja-47313bca65de105145f2168538b294a9bcc0e98d.tar.gz
backupninja-47313bca65de105145f2168538b294a9bcc0e98d.tar.bz2
ldap,mysql,pgsql: use bash pipefail option so that failed dumps are reported as such
This should fix Redmine bug #1340. This option makes pipelines return as status the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. See bash(1) for details. E.g. this prevents the following from exiting with status 0 (!) if pg_dumpall fails: pg_dumpall | gzip
Diffstat (limited to 'handlers/mysql.in')
-rw-r--r--handlers/mysql.in8
1 files changed, 4 insertions, 4 deletions
diff --git a/handlers/mysql.in b/handlers/mysql.in
index f3230ad..3488c51 100644
--- a/handlers/mysql.in
+++ b/handlers/mysql.in
@@ -237,14 +237,14 @@ then
then
if [ $usevserver = yes ]
then
- debug 'echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database'
- databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
+ debug 'set -o pipefail ; echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database'
+ databases=`set -o pipefail ; echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
fi
else
- databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
+ databases=$(set -o pipefail ; su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
if [ $? -ne 0 ]
then
fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
@@ -298,7 +298,7 @@ then
debug "su $user -c \"$execstr\""
if [ ! $test ]
then
- output=`su $user -c "$execstr" 2>&1`
+ output=`su $user -c "set -o pipefail ; $execstr" 2>&1`
code=$?
if [ "$code" == "0" ]
then