I've been trying different things without success
so here is what I want to achieve
set -o pipefail
dump "$@" "$db" | compress | store "single" "$(backupName "$db")"
# I would want something that behaves a bit like this
# meaning if it dump fails, don't store
dump "$@" "$db" && {
#migicGetStdout | compress | store "single" "$(backupName "$db")"
} || {
echo failed
}
But it creates a empty file on failed dump
I'm lost with pipeline
I've tried things like
set -e
set -o pipefail
dump "${dumpCommonArgs[@]}" "${dumpDbArgs[@]}" "$@" "$db" > >(compress | store "single" "$(backupName "$db")")
# or
( compress | store "single" "$(backupName "$db")" ) < <(dump "$@" "$db") || return 2
# or
## this way compress get the global $@ ... I don't understand that either
store "single" "$(backupName "$db")" < <(dump "${dumpCommonArgs[@]}" "${dumpDbArgs[@]}" "$@" "$db") > >(compress)
# there would be an easy one
dataToStore=$(dump "$@" "$db")
rc=$?
# but this means dump is stored in memory before saving... not the best deal as mysql already needs a lot of ram to run a dump
store function is still called!
So seems I'm missing something.
Thanks for helping me out