summaryrefslogtreecommitdiff
blob: 6cbf58c2643170e5c325a2af307161ea2ee45d89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash

if [ "x$1" == "x--help" ]; then
  echo "Usage: mysql-dump-all mysql-root-pass /backup/dir"
  echo
  echo "Dumps all mysql databases into the given /backup/dir/"
  exit 0
fi

DBS=`mysql -u root -p${1} -s -e 'show databases;' | grep -v 'Database'`

for db in $DBS
do
  mysqldump -u root -p${1} ${db} > ${2}/${db}.sql 
done