mysql error messages may clobber backups
I have yet to reproduce this or find a case where it is critical, but this code strikes me as a recipe for disaster:
if [ "$compress" == "yes" ]; then execstr="$DUMP | $GZIP > '$dumpdir/${db}.sql.gz'" else execstr="$DUMP -r '$dumpdir/${db}.sql'" fi fi debug "su $user -c \"$execstr\"" if [ ! $test ] then output=@su $user -c "$execstr" 2>&1@
Here, if the dbs are compressed, the redirect will be something like this:
mysqldump | gzip > foo.sql 2>&1
Which means that errors will go to foo.sql. This is not what we want. Proof of my theory:
anarcat@mumia [~]$ echo just to stdout just to stdout anarcat@mumia [~]$ ( echo to stderr >&2 ) to stderr anarcat@mumia [~]$ ( echo to stderr >&2 ) > /dev/null to stderr anarcat@mumia [~]$ ( echo to stderr, returning to stdin >&2 ) > test 2>&1 anarcat@mumia [~]$ cat test to stderr, returning to stdin
This is bad, because any error from mysql will corrupt the sql dump.
(from redmine: created on 2009-01-20, closed on 2010-01-08)