A simple MYSQL backup script

Hello,

I use rsnapshot to does the incremental restore.

With snapshot I use a maid home mysql backup script.

You may change it to feat your needs.

It is very simple but the most important is it works just fine.

PATH2DB=/var/lib/mysql

RSLT=ls -1 --ignore mysql.sock --ignore <MYFQDN>.err /$PATH2DB

for tocreate in $RSLT; do
#echo “backup de la base $tocreate dans $tocreate”
mysqldump -u root $tocreate > $tocreate.sql

done

You’d surely prefere have something like this

PATH2DB=/var/lib/mysql
PATH2BCKUP = /my/backup/path

RSLT=ls -1 --ignore mysql.sock --ignore <MYFQDN>.err /$PATH2DB

for tocreate in $RSLT; do
#echo “backup de la base $tocreate dans $tocreate”
mysqldump -u root $tocreate > $PATH2BCKUP/$tocreate.sql

done

I prefere do this rather than a --all-databases option because it allow to quicly find and restore a sepcific user database

You’d change --ignore <MYFQDN> to your Full qualified domain name for example server1.domain.tld.
You may find in /var/lib/mysql all the <FQDN>.err and write what you find in the ignore option.

To whom it may help

Pascal