#!/bib/sh # shell script to backup all mysql db to disk(/var/lib/mysql) # # last update: 2009-11-06 # edit to your needs PROGNAME=$0 ROOTPW="0000" DUMPFILE="/var/lib/mysql/alldb" mysqldump --add-drop-table --quote-names -u root -p$ROOTPW --all-databases > $DUMPFILE.tmp r=$? if [ "$r" != "0" ] ; then logger "$PROGNAME - db dump failed!" exit 1 fi sync # shift the current dump to backup dump rm -f $DUMPFILE.bak mv $DUMPFILE.current $DUMPFILE.bak mv $DUMPFILE.tmp $DUMPFILE.current sync exit 0