#!/bin/sh # # $Id: mysqlbackup.sh 8624 2010-10-31 23:16:34Z rick $ # Poor mans mysql database backup. # Rick van der Zwet BACKUP_ROOT="/usr/backup/`hostname -s`/mysqlbackup" MYSQL_AUTH=`cat /root/.mysql_root_auth` || exit 1 export PATH=$PATH:/usr/local/bin # All available database DATABASES=`echo 'show databases' | mysql --skip-column-names $MYSQL_AUTH` BACKUP_TODAY=`date "+$BACKUP_ROOT/%Y/%m/%d/"` mkdir -p $BACKUP_TODAY # Dump and compress for DATABASE in $DATABASES; do TIMETAG=`date "+%H:%M:%S"` mysqldump $MYSQL_AUTH --skip-lock-tables $DATABASE | gzip > $BACKUP_TODAY/$DATABASE-$TIMETAG.sql.gz done