Projects / MySQL Backup / Comments

Comments for MySQL Backup

04 Aug 2004 06:16 wfmh

Re: It does what it says and is quite cool
More less same in bash - not for general use out of the box but just copy of one of my tools. Probably would need some tweaking for others (i.e. I do md5sum twice for each dump - you may not be so adminish ;)


#!/bin/bash

TARGET=/BACKUP

export DT=`date +"%Y%m%d_%H%M"`

export DESTDIR=${TARGET}/`date +"%Y%m%d/mysql"`

TMPNAME=_dump_sql_tmp_$$

function Backup()

{

local SERVER

SERVER=$1

BASE="$SERVER"_${DT}

CURDIR=`pwd`

echo " ${SERVER} to ${BASE}: "

DEST=${DESTDIR}/${SERVER}/${DT}

mkdir -p ${DEST}

cd ${DEST}

# getting list of databases...

echo "SHOW DATABASES;" | mysql -pPASSWORD -u USER -h ${SERVER} > ${TMPNAME}

while read DB

do

if [ $DB != "Database" ]; then

echo -n " ${DB}: "

mysqldump -Q --all --complete-insert --quote-names --add-drop-table -pPASSWORD -u USER -h ${SERVER} ${DB} >${BASE}_${DB}.mysql

echo -n "md5"

md5sum -b ${BASE}_${DB}.mysql >${BASE}_${DB}.md5sum

echo -n ", tar"

tar --remove-files -zcf ${BASE}_${DB}.tgz ${BASE}_${DB}.*

echo ", md5"

md5sum -b ${BASE}_${DB}.tgz >${BASE}_${DB}.md5sum

fi

done < ${TMPNAME}

rm -f ${TMPNAME}

cd ${CURDIR}

echo "Done."

}

# Call for all your servers

Backup localhost

Backup my.othersever.com

02 Jun 2004 05:33 oberger

It does what it says and is quite cool
Very interesting tool, that does what it says and provides detailed logs of what was done

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.