Last active
August 4, 2016 18:30
-
-
Save thomasjsn/60e39c11daae90365e3737066431c7e4 to your computer and use it in GitHub Desktop.
Export all databases that the user can access, then sync the sql files to a s3 bucket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER="backup" | |
PASSWORD="password" | |
OUTPUT="/output/folder" | |
BUCKET="backup-bucket" | |
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database` | |
for db in $databases; do | |
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then | |
echo "Dumping database: $db" | |
mysqldump -u $USER -p$PASSWORD --databases $db > $OUTPUT/`date +%Y%m%d`.$db.sql | |
fi | |
done | |
s3cmd sync $OUTPUT/ s3://$BUCKET/sql/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment