set -euo pipefail, and the pipeline exit code you assumed

A shell pipeline reports the exit code of the last command, so mysqldump | gzip > file succeeds when the dump fails and the gzip writes nothing.

#!/usr/bin/env bash
set -euo pipefail

# -e            exit on error
# -u            an unset variable is an error, not an empty string
# -o pipefail   a pipeline fails if ANY stage fails

mysqldump shop | gzip > /backup/shop.sql.gz     # now this can fail

pipefail is the one that catches silent data loss, and its absence is why so many backup scripts have been reporting success for years. -u catches the other classic: rm -rf $PREFIX/$DIR with an unset variable becomes something considerably worse. Note that -e does not apply inside a condition, which is why if ! grep -q ... works — that exemption is deliberate and worth knowing before writing a workaround.