Skip to content

Instantly share code, notes, and snippets.

@codemilli
Created June 25, 2017 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemilli/2e04e85c53983b82216b1cdba050fdca to your computer and use it in GitHub Desktop.
Save codemilli/2e04e85c53983b82216b1cdba050fdca to your computer and use it in GitHub Desktop.
#!/bin/bash
cd /tmp
file=$(date +%a).sql
mysqldump \
--host ${MYSQL_HOST} \
--port ${MYSQL_PORT} \
-u ${MYSQL_USER} \
--password="${MYSQL_PASS}" \
${MYSQL_DB} > ${file}
if [ "${?}" -eq 0 ]; then
gzip ${file}
aws s3 cp ${file}.gz s3://${S3_BUCKET}
rm ${file}.gz
else
echo "Error backing up mysql"
exit 255
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment