MySQL Backup and Rotation

#!/bin/bash
#Simple Database Backup and Rotation Utility
#Run from crontab nightly as root
#00 0    * * *   root    /root/bin/dump-dbs.sh
 
 
DATE=`date +%Y%m%d-%a`
DBS=`mysql -e "show databases" | awk '{ print $1 }' | tr '\n' ' ' | cut -b10-`
 
 
#Where to store your .sql backups
cd /root/MySQL-Backup
 
 
#Remove Previous Week's Backup
rm -f *-`date +%a`.sql
 
 
for i in $DBS ;
    do mysqldump --opt --allow-keywords --quote-names --result-file=$i-$DATE.sql $i;
done