Backup MySQL, Old School Style

Our standard backup software at work decided to crap out on one of our more critical servers. I decided to write up a little mysqldump script to get database copies while we troubleshoot our backup agent. The destination is an NFS share to a separate computer node on a separate storage infrastructure. I'll use rsync to create incremental sets of data for the nightly backup job to tape on that NFS server. #!/bin/bash BKFLDR=/backups/server_name # get the list of databases DATABASES=`mysql -e "show databases" | tail -n +2` for DATABASE in ${DATABASES[@]} do # create a folder with the same name as the database if [ ! -d $BKFLDR/$DATABASE ] then mkdir -p $BKFLDR/$DATABASE fi # run the backup while creating individual files for each table mysqldump --flush-logs --single-transaction $database --tab=$BKFLDR/$DATABASE done

This is a personal website. Unless otherwise stated, the content and opinions expressed here are my own and not those of my employer.