Skip to content

Instantly share code, notes, and snippets.

@nilkesede
Last active March 3, 2022 08:58
Show Gist options
  • Save nilkesede/8e8ffc601201f6cb86f8dc14fd736dca to your computer and use it in GitHub Desktop.
Save nilkesede/8e8ffc601201f6cb86f8dc14fd736dca to your computer and use it in GitHub Desktop.
Dump from remote mysql
#!/bin/bash
host=$1
user=$2
password=$3
folder=$4
filter=''
if [ -n "$5" ]; then
filter=" like '$5'"
fi
databases=`mysql -h$host -u$user -p$password -e "show databases$filter" -s --skip-column-names --ssl-mode=DISABLED`
for DB in $databases; do
echo $DB
mysqldump -h$host -u$user -p$password --ssl-mode=DISABLED $DB > "./$4/$DB.sql";
# docker exec -i mysql57
# --column-statistics=0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment