#!/bin/sh # # $Id: mysqlbackup.sh 8548 2010-10-04 19:41:22Z rick $ # Poor mans mysql database backup. # Rick van der Zwet BACKUP_ROOT='/usr/local/backup/mysqlbackup' MYSQL_AUTH='-uroot' 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