Skip to content

Instantly share code, notes, and snippets.

@andyj
Last active April 2, 2019 08:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyj/4f59734802ea9d9941945e9836354111 to your computer and use it in GitHub Desktop.
Save andyj/4f59734802ea9d9941945e9836354111 to your computer and use it in GitHub Desktop.
Bash script to backup a MySQL RDS dump to S3
# From Andy Jarretts post:
# http://www.andyjarrett.co.uk/2016/08/02/secured-bash-script-to-backup-a-mysql-rds-dump-to-s3/
#!/bin/bash
SQLDUMP="$(date +'%Y%m%d%H%M').sql.gz"
echo "Creating backup of database to $SQLDUMP"
mysqldump --login-path=local --databases YourDatabaseName | gzip -9 > $SQLDUMP
echo "Dump Zipped up"
echo "Uploading zipped dump to the Amazon S3 bucket…"
s3cmd put $BACKUPNAME s3://bucketname/backup/folder/$BACKUPNAME
echo "Removing the backup file $SQLDUMP"
rm $BACKUPNAME
echo "WooHoo! All done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment