Howto Backup a MySQL database to gmail
I wrote this little script ages ago and it has indeed saved my ass. It may be ghetto but a good friend and much better SA than I thought it was clever so here it is:
“export d=`date +%F`
mysqldump –opt -u yourDBuser –password=YourDBpassword yourDatabaseName |gzip -f >yourdatabase.db.$d.gzip
uuencode yourdatabase.db.$d.gzip yourdatabase.db.$d.gzip | mail YourGmailAddy@gmail.com”
That’s it! You get a free cloud based backup system for your database. It just shows up as an attachment in your gmail. Simply download the attachment (it seems gmail now uudecodes for you) and restore your db with “mysql -p HosedDataBasename < AttachmentFileName”
Add the script to your crontab and you’re done. Of course you have to be mindful of the gmail attachment size limit which is currently ~25megs. Of course you could break a larger db down into smaller files but I’m hoping you’d have graduated from a ghetto solution like this if you’re backing up your 1TB database.