-
-
Save josemalcher/62057c1edd7f4e64d4d9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
####################### ATENCAO ######################### | |
# | |
# VI ESTA DICA EM ALGUM GIST, MAS NÃO TENHO MAIS A URL | |
# POREM EU ALTEREI PARA FAZER BACKUP DE TODAS AS BASES | |
# E ADICIONEI A QUESTÃO DE PODER ADICIONAR O USUÁRIO | |
# E EMAIL NA LINHA DE COMANDO DO git | |
# | |
######################################################### | |
#se você usar apenas usuário sem senha, use este linha abaixo | |
usuarioesenha="-u henrique" | |
#se usar usuário e senha use esta outra linha | |
#usuarioesenha="-u henrique -psenha" | |
databases=(`mysql -e "show databases" ${usuarioesenha}`) | |
# | |
# MYSQL DUMP | |
for database in "${databases[@]}" | |
do | |
if [ $database != "Database" ] && [ $database != "information_schema" ] && [ $database != "performance_schema" ]; then | |
echo "dump $database" | |
mysqldump ${usuarioesenha} ${database} > "/interno/git-backup/sql/$database.sql" | |
fi | |
done | |
# GIT | |
cd /interno/git-backup | |
/usr/bin/git add sql/* | |
/usr/bin/git -c user.name='Cron' -c user.email='cron@crontab' commit -m "Backup sql `date +%d-%m-%Y\ %H:%M:%S`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vídeo explicando! https://www.youtube.com/watch?v=aD-ostGctQg