I have created the following shell scrip to backup MySQL DB, zip it, and then copy it to an s3 bucket:
#vim /home/ubuntu/backup/mysqlbackup2.sh #!/bin/bash ## Backup mysql DB, zip it and then copy it to s3 bucket mysqldump -hhostname -uusername dbName -p'p@ssW0rd' > db.sql if [ $? -le 1 ] then # zip the file and copy it s3 bucket sudo gzip -9 db.sql s3cmd put db.sql.gz s://mys3bucket/ else echo "Fail to backup MySQL DB" >> "backup.log" fi
It does everything fine and the backup is copied to s3 bucket. But I cannot understand the output of shell script:
I understand the password warning but why does it show:
'[' 0 -le 1 ']'? Is there anything wrong in my if condition?