Você pode usar este script:
#!/bin/bash
BACKUP_DIR="/opt/backup"
MYSQL_USER=your_user
MYSQL_PASS=your_pass
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
DB_LIST="$($MYSQL -u $MYSQL_USER -p$MYSQL_PASS -Bse 'show databases')"
for db in $DB_LIST;
do
BACKUP_SUBDIR="$BACKUP_DIR/mysql_'date +%Y-%m-%d'"
BACKUP_FILE="$BACKUP_SUBDIR/$db.gz"
if [ ! -d $BACKUP_SUBDIR ]; then
mkdir -p $BACKUP_SUBDIR
fi
if [ -f $BACKUP_FILE ]; then
unlink $BACKUP_FILE
fi
$MYSQLDUMP -u $MYSQL_USER -p$MYSQL_PASS $db | $GZIP -9 > $BACKUP_FILE
done