#!/bin/bash if ! test -x /usr/bin/mysql ; then exit 0 fi backup_dir=/var/backups/mysql databases=$(mysql --defaults-file=/etc/mysql/debian.cnf -B -N --execute="SHOW DATABASES" | grep -v 'lost+found\|performance_schema\|information_schema') for db in $databases ; do mkdir -p $backup_dir chmod 700 $backup_dir mysqldump --defaults-file=/etc/mysql/debian.cnf --events $db | bzip2 - > $backup_dir/$db.sql.bz2 done