mysqldump --verbose -h $dbhost --max_allowed_packet=1G --extended-
insert --single-transaction --add-drop-database --opt $dbname --
user=$dbusername --password=$dbpassword | gzip -1 > $filename.sql.gz
echo $?
I'm using the above code in my bash script to take a mysql dump and gzip it.
I want to confirm the mysqldump was successful before allowing the script to continue running. If for example the host isn't found how can i catch that error?
I am unsure as to how to achieve this. Current output i get with the above is as follows:
mysqldump: Got error: 2005: Unknown MySQL server host 'test' (0) when
trying to connect
0
why am i getting a 0 success code when the host wasn't found? I think it's because the gzip is still successful in that it produces an empty file...but i dont know how to work around this.