Resource icon

Backup All MySQL Databases

Bash:
#! /bin/bash

BACKUP_DIR="/root/dbbackups"
MYSQL_USER="root"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="PASSWORD"
MYSQLDUMP=/usr/bin/mysqldump

databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`

for db in $databases; do
  $MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$db.gz"
done
Author
Matt
Views
797
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Matt

Back
Top