MySQL Backup Script

I’ve switch to a new hosting company Dreamhost. I highly recommend them and if you need tons of savings google “dreamhost promo code” to get up to $97.00 bucks off your first year or two year subscription fee. My top hosting company choices were my previous hosting company for ai MediaTemple and Dreamhost. I choose Dreamhost because of the kick ass promo codes available from them and just the vast amount of options they provide. Initially, I was worried about the downtime they were having in the past months, but I also learned that MediaTemple collocates to the same building as some other major hosting companies so it just wasn’t Dreamhost with downtime. But as I continued to read on their blog, they are proactive at maintenance, upgrading data centers, so on and so on. I was quite satistfied with the hosting options they provided with the continual addition of bandwidth and storage on a weekly basis like what gmail does to storage however the blog probably helped me make the final decision to go with them. Anyway, I’ll write a more indepth post about them later. One of the options they provide is shell access (greeaaaat!) and from the indepth documentation they have online, here is a simple mysql backup script based on their script.


#! /bin/bash
cd ~/backups/mysql
dsuffix=$(date +%m%d%y)
tsuffix=$(date +%T)
mysqldump --opt -u username -ppassword -h sqlhost database > database_backup.$dsuffix.$tsuffix.sql
cat “database_backup.$dsuffix.$tsuffix.sql” | mail youremail@yourdoman.com

Make sure to replace the bolded text with your info. Also that’s not a mistake at -ppassword. If there is a space the script with prompt you for a password it’s completely up to you.

3 Responses to “MySQL Backup Script”

  1. alex c Says:

    Hi,
    Small correction. We - (mt) Media Temple are no longer in the same datacenter. We have moved our operations to a more secure data center that is the highest rated one in Southern California (TIER4 Data Center rating).

    Dreamhost has some great plans and if your site is for personal use I highly recommend them….Have you seen our new (gs) Grid-Server entry level plan. Many cool one clicks, lots of space and the death of the Shared Server for us! You can also find a coupon here for your order: www.inconcrete.com

    Apologies for ranting about the Grid-Server…veryh excitied about it…cheers!
    Alex Capehart

  2. Steve Covell Says:

    Thanks Alex! To be fair Media Temple took care of my personal needs for three years with absolutely no downtime (at least from my knowledge), but it came down to cost cutting at least for the next two years. From researching some of my favorite bloggers - it was pretty split in the middle between Media Temple and Dreamhost. Most of the Media Temple hosting more on the heavy side on dedicated servers. Thanks again for your post.

  3. Alex C Says:

    no worries and I totally understand. Our stuff can be overkill for some things. Best of luck and see ya on the internets.

    Alex C @ (mt)

Leave a Reply