#!/bin/bash

MYSQL_DIR=”/var/lib/mysql”

MYSQL_DUMPS=”/archives”

DB_ACCOUNT=”root”

DB_PASSWORD=”password”

echo “Dumping databases”

for i in $(find ${MYSQL_DIR} -type d -exec basename {} \;)

do

case ${i} in

test | mysql )

echo “Skipping database: ${i}”

;;

* )

echo “Dumping database: ${i} @ $(date)”

mysqldump -u${DB_ACCOUNT} -p${DB_PASSWORD} –quick ${i} > ${MYSQL_DUMPS}/$(date +%y%m%d).${i}.sql

echo “Compressing dump of ${i} @ $(date)”

gzip ${MYSQL_DUMPS}/$(date +%y%m%d).${i}.sql

;;

esac

done

echo “Completed @ $(date)”

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>