Skip to content

Instantly share code, notes, and snippets.

@marcelog
Created May 11, 2016 14:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marcelog/2d50b295e8641d45a32b3269b42e8eb3 to your computer and use it in GitHub Desktop.
Save marcelog/2d50b295e8641d45a32b3269b42e8eb3 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
@ikhan009
Copy link

i face error, when i run this script. i keep port 3306

  1. --password=${password123}: bad substitution
    Error backing up mysql
  2. "Unknown MySQL server host '--port' (2)" when trying to connect
    Error backing up mysql

our method is down.
mysqldump
--host ${localhost}
--port ${3306}
-u ${user123}
--password="${password123}"
${database123} > ${file}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment