Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josemalcher/62057c1edd7f4e64d4d9 to your computer and use it in GitHub Desktop.
Save josemalcher/62057c1edd7f4e64d4d9 to your computer and use it in GitHub Desktop.
#!/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`"
@josemalcher
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment