#!/bin/sh # This will dump your MySQL databases DATE=$(date +%Y%m%d%H%M) for DB in $(echo "show databases" | mysql --defaults-file=/etc/mysql/debian.cnf -N) do mysqldump --defaults-file=/etc/mysql/debian.cnf $DB > /var/lib/automysqlbackup/${DB}_${DATE}.sql gzip /var/lib/automysqlbackup/${DB}_${DATE}.sql done # purge old dumps find /var/lib/automysqlbackup/ -name "*.sql*" -mtime +8 -exec rm -vf {} \;