Bash:
#! /bin/bash
BACKUP_DIR="/root/dbbackups"
MYSQL_USER="root"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="PASSWORD"
MYSQLDUMP=/usr/bin/mysqldump
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$db.gz"
done