Skip to content

Instantly share code, notes, and snippets.

@daum
Created May 3, 2013 19:08
Show Gist options
  • Save daum/5512948 to your computer and use it in GitHub Desktop.
Save daum/5512948 to your computer and use it in GitHub Desktop.
#!/bin/bash
SQL_FILE="$(date +%m-%d-%y).sql"
mysqldump -ubackupuser -p'backupuser-password' --all-databases > "$SQL_FILE"
RC = $?
if [[ $RC != 0 ]] ; then
echo "Failure, mysqldump failed to dump"
exit $RC;
fi
gzip "$SQL_FILE"
RC = $?
if [[ $RC != 0 ]] ; then
echo "Failure, gzip failed to zip!"
exit $RC;
fi
s3cmd put $SQL_FILE.gz s3://mybackup-db/$SQL_FILE.gz
RC = $?
if [[ $RC != 0 ]] ; then
echo "Failure, s3cmd failed to put file in bucket"
exit $RC;
fi
rm $SQL_FILE.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment