Suppose you have a line
mysqldump | gzip
in your script.
Then the exit status code will be of gzip, rather than mysqldump, while the most likely process to fail here is mysqldump.
To fix this, add this at the top of your bash scripts:
set -o pipefail