dockerfiles icon indicating copy to clipboard operation
dockerfiles copied to clipboard

mysql-backup-s3: set '-o pipefail' to catch errors when database not found

Open byrnedo opened this issue 8 years ago • 7 comments

Hi,

You have 'set -e' at the top of the backup.sh script.

Right now, the mysqldump ...|gzip... command wont fail if mysqldump returns an error.

If you add

set -eo pipefail

It'll catch that. You could also add `set -euo pipefail' to catch unset variables too.

I assume this affects other images you have too.

byrnedo avatar Oct 11 '17 07:10 byrnedo

@byrnedo That's a good idea. Could you please make a PR ?

OlivierCuyp avatar Jul 20 '18 20:07 OlivierCuyp

@OlivierCuyp done. Sh doesn't support -u and either way it would have probably broken certain scripts, so I just changed it to -eo pipefail. Are there any tests one can run to confirm?

byrnedo avatar Jul 27 '18 12:07 byrnedo

@byrnedo sorry for the late answer. There no real tests. From what I read I guess you tested it on your side. If you confirm so I would merge the PR.

OlivierCuyp avatar Aug 19 '18 19:08 OlivierCuyp

No, haven't tested it

byrnedo avatar Aug 20 '18 07:08 byrnedo

Ok, I'll dedicate some time to test it then ;)

OlivierCuyp avatar Aug 21 '18 08:08 OlivierCuyp

I can help out too, not sure how one would test this though, so many different images. Any opinion on what tools to use to test this? Bats or Goss?

byrnedo avatar Aug 21 '18 08:08 byrnedo

Hi @byrnedo, thanks for your proposal. I have no experience with both of these test frameworks. I would say choose the one you feel more confortable with.

OlivierCuyp avatar Aug 21 '18 10:08 OlivierCuyp