git clone http://git.rg1.ru/artem/mysql_dump.git
cd ./mysql_dump
./main.sh -u USER -pPASS ...
Created
March 12, 2019 22:00
-
-
Save artembeloglazov/5ab1ec726f05a6ae333cfd46c2fbd979 to your computer and use it in GitHub Desktop.
Full mysql dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cmd="mysqldump $*" | |
cmd_db_list="mysql $* -e 'SHOW DATABASES;'" | |
databases=`eval $cmd_db_list | tr -d "| " | grep -v Database` | |
for db in $databases; do | |
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then | |
echo "Dumping database: $db" | |
dyn_cmd="$cmd --databases $db" | |
cur_date=`date +%Y%m%d` | |
file_name=$cur_date.$db.sql | |
eval $dyn_cmd | tee $file_name | |
#eval $dyn_cmd > date +%Y%m%d.$db.sql | |
# gzip $OUTPUT/`date +%Y%m%d`.$db.sql | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment