Last active
December 16, 2020 20:33
-
-
Save aristidesneto/dee35d878fac3d031d218630f40ea925 to your computer and use it in GitHub Desktop.
Revisions
-
aristidesneto revised this gist
Dec 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # # Autor: Aristides Neto # Email: [email protected] # # Data: 09/06/2019 # -
aristidesneto revised this gist
Nov 22, 2019 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -47,8 +47,9 @@ echo "MYSQLDUMP Iniciado em $DATA_INICIO" >> $LOG # Loop para backupear todos os bancos for db in "${DATABASES[@]}"; do # Mysql DUMP # Para backupear procedures e functions foi adicionado o --routines mysqldump --routines -u$USER -p$PASS $db > $DIR_BK/$db'_'$DATA_ATUAL.sql echo "Realizando backup do banco ...............[ $db ]" >> $LOG # Compacta o arquivo sql em BZ2 -
aristidesneto revised this gist
Jun 10, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Autor: Aristides Neto # Email: [email protected] # # Data: 09/06/2019 # # Realiza o backup de bancos de dados MySQL # -
aristidesneto revised this gist
Jun 10, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Autor: Aristides Neto # Email: [email protected] # # Data: 09/062019 # # Realiza o backup de bancos de dados MySQL # -
aristidesneto created this gist
Jun 10, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ #!/bin/bash # # Autor: Aristides Neto # Email: [email protected] # # Data: Junho 2019 # # Realiza o backup de bancos de dados MySQL # # Define usuario e senha do banco USER='root' PASS='root' # Datas DIA=`date +%d` MES=`date +%m` ANO=`date +%Y` DATA_ATUAL=`date +%Y-%m-%d-%H-%M` # Data de Inicio do Backup DATA_INICIO=`date +%d/%m/%Y-%H:%M:%S` # Caminho do arquivo de log LOG_DIR=/var/log/backup LOG=$LOG_DIR/backup_db_$ANO$MES$DIA.log # Diretorio onde serão salvos os backups DIR_BK=/var/backups/database # Lista dos bancos de dados que serão realizados o backup DATABASES=(banco01 banco02) # Verifica se existe o diretorio para armazenar os logs if [ ! -d $LOG_DIR ]; then mkdir $LOG_DIR fi # Verifica se existe o diretorio para o backup if [ ! -d $DIR_BK ]; then mkdir -p $DIR_BK fi # Inicio do backup echo "MYSQLDUMP Iniciado em $DATA_INICIO" >> $LOG # Loop para backupear todos os bancos for db in "${DATABASES[@]}"; do # Mysql DUMP mysqldump -u$USER -p$PASS $db > $DIR_BK/$db'_'$DATA_ATUAL.sql echo "Realizando backup do banco ...............[ $db ]" >> $LOG # Compacta o arquivo sql em BZ2 bzip2 $DIR_BK/$db'_'$DATA_ATUAL.sql done DATA_FINAL=`date +%d/%m/%Y-%H:%M:%S` echo "MYSQLDUMP Finalizado em $DATA_FINAL" >> $LOG # Remove arquivos de backups antigos - 5 dias find $DIR_BK -type f -mtime +5 -exec rm -rf {} \;