mysql dump all datbases to separate files

This is fast way to backup all MySQL database to separate files:

back_dir=/backups/databases/$(date +'%F')
mkdir -v -p $back_dir

mysql -s -e 'show databases' | egrep -v "information_schema|performance_schema" | while read db; do mysqldump -h localhost --single-transaction --events --ignore-table=mysql.event $db > $back_dir/$db.$(date +'%F').sql; [[ $? -eq 0 ]] && gzip $back_dir/$db.$(date +'%F').sql ; done

Leave a Reply

Your email address will not be published. Required fields are marked *