Skip to content

Instantly share code, notes, and snippets.

@artembeloglazov
Created March 12, 2019 22:00
Show Gist options
  • Save artembeloglazov/5ab1ec726f05a6ae333cfd46c2fbd979 to your computer and use it in GitHub Desktop.
Save artembeloglazov/5ab1ec726f05a6ae333cfd46c2fbd979 to your computer and use it in GitHub Desktop.
Full mysql dump

Скрипт архивирования всех таблиц указанного сервера mysql

Использование

git clone http://git.rg1.ru/artem/mysql_dump.git
cd ./mysql_dump
./main.sh -u USER -pPASS ...
#!/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