Conditional commands in ssh & shell & mysql

view story

http://stackoverflow.com – I have the following commands in a shell script where I do a mysql dump, then I load that SQL file over ssh into a remote database, and then I update the timestamp. 1. mysqldump -u root files path | gzip -9 > $SQL_FILE 2. cat $SQL_FILE | ssh -i ~/metadata.pem [email protected] "zcat | mysql -u 'root' -h metadata" 3. TIMESTAMP=`date "+%Y-%m-%d-%T"` 4. mysql -u 'root' -h metadata -e "UPDATE path_last_updated SET timestamp=DEFAULT" Is there any way to improve the above commands. For example, what happens if line 2 fails (for example, due to a connectivity issue), but line (HowTos)