Last active
May 17, 2016 18:58
-
-
Save lucassmacedo/8a9d507425feef607960fc6106c5fbda to your computer and use it in GitHub Desktop.
Export all databases on mysql
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 | |
#Por : Lucas Macedo | |
#se você usar apenas usuário sem senha, use este linha abaixo | |
usuarioesenha="-u root -proot" | |
#pasta para exportação do banco | |
pasta_backup="/Users/Lucas/backup_banco" | |
#define o path do mysql, se estiver global deixe apenas "mysql" ex: C:\wamp\bin\mysql\mysql5.6.12\bin\mysql | |
_mysql="/Applications/MAMP/Library/bin/mysql" | |
#define o path do mysqldump, se estiver global deixe apenas "mysqldump" ex: C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump | |
_mysqldump="/Applications/MAMP/Library/bin/mysqldump" | |
databases=(`$_mysql -e "show databases" ${usuarioesenha}`) | |
if [ -d "$pasta_backup" ]; | |
then | |
#MYSQL DUMP | |
for database in "${databases[@]}" | |
do | |
if [ $database != "Database" ] && [ $database != "information_schema" ] && [ $database != "performance_schema" ]; then | |
echo "Exportando banco: $database" | |
$_mysqldump ${usuarioesenha} ${database} > "$pasta_backup/$database.sql" | |
fi | |
done | |
else | |
echo "Caminho : $pasta_backup não encontrado" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment