Skip to content

Instantly share code, notes, and snippets.

@riccamastellone
Created July 25, 2013 09:51
Show Gist options
  • Save riccamastellone/6078351 to your computer and use it in GitHub Desktop.
Save riccamastellone/6078351 to your computer and use it in GitHub Desktop.
Extremely simple script to list and backup all your MySQL dbs to Amazon S3 using s3cmd (http://s3tools.org/).
#!/bin/bash
dblist=`mysql -u root -pYOURPASSWORD -e "show databases" | sed -n '2,$ p'`
for db in $dblist; do
if [ $db != 'performance_schema' ] && [ $db != 'mysql' ] && [ $db != 'information_schema' ]
then
mysqldump -u root -pYOURPASSWORD $db > /var/backup/db/$db.sql
s3cmd --no-progress --mime-type="application/octet-stream" put /var/backup/db/$db.sql s3://YOURBUCKET/backup-db/$db.sql
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment