DISQUS

Aditya Kothadiya: Automating Your MySQL Database Backup On Media Temple’s Grid-Server

  • Mike Marley · 7 months ago
    You might be able to make this a bit sweeter. Wouldn't it be nice if you didn't have to know the names of all your databases. Perhaps changing line 7 to this instead:

    for DATABASE in `mysqlshow -udbXXXXX -pPASSWORD -h internal-db.sXXXXX.gridserver.com | grep '^|'|grep -v Databases | cut -f 2 -d ' '`

    No guarantees but that might work.

    Mike Marley
    Technical Communications
    (mt) Media Temple
  • Alex Kendrick · 5 months ago
    This worked great for me to back up my (mt) databases. Thank you!!
  • Al · 3 months ago
    Everything seems to be working except the date stamping, all the databases are output dbname.sql.gz
  • Al · 3 months ago
    Please ignore this comment, i figured it out
  • thelittlemermaid22 · 2 months ago
    I have used this script on my mediatemple server and it works great. A many thanks for writing this article. Its really very useful. I have made(and want to make) a few modifications to this script. For eg. I have modified the date variable to timestamp like this - DATE=`date +%Y-%m-%d.%H%M%S`. Now I want that it should delete the last 4 days backup, nut thats not happening. I need to go and manually delete the backup files. Can you please tell me how should I do it?

    Many thanks.
  • Clint · 2 months ago
    Thanks for this. I followed directions, but I keep getting this error when I try to test:

    ./db_backup.sh
    : bad interpreter: No such file or directory


    If I try "bash db_backup.sh" I get this error:
    : command not found6:
    'b_backup.sh: line 8: syntax error near unexpected token `do
    'b_backup.sh: line 8: `do


    Any suggestions? I can't wait to get this working. Thanks again.
  • Marc Gayle · 1 month ago
    Clint,
    Not sure if you figured it out, but basically what you want to do is make sure that the line-endings are in the Unix-friendly 'LF' format.

    That's what fixed it for me.

    Also, another issue I found with the script that I fixed was the path. It kept giving me a 'file or folder cannot be found' error. All I did was change the XXXXX from my gridserver/account number to my primary domain name. It seems that MediaTemple has both stored - I guess the gridserver number works for some clients, but for me only the primary domain worked.

    Hope that works for you.
  • starksilvercreek · 1 month ago
    Marc, thanks! I'll give that a try. Appreciate the tips. Clint
  • Marc Gayle · 1 month ago
    I second Clint's error.

    That's what I keep getting.