Backup utilizando rsync com envio do log e informativo via e-mail

Publicado por Daniel Padovani (última atualização em 17/06/2015)

[ Hits: 8.537 ]

Download bkp.zip




Fácil de configurar e após o término envia o log por e-mail.

Como instalar:

Copie o arquivo sendEmail para /usr/local/bin:

# cp sendEmail /usr/local/bin

Adicione permissão de execução:

# chmod +x /usr/local/bin/sendEmail
# chmod +x backup_rsync.sh

Agora basta ajustar o backup_rsync.sh e adicionar no cron com a periodicidade desejada.
No download já existe tanto o backup_rsync.sh quanto o sendEmail.

O sendEmail foi escrito por: Brandon Zehm <caspian[at]dotconf.net>.

    License:
    sendEmail (hereafter referred to as "program") is free software;
    you can redistribute it and/or modify it under the terms of the GNU General
    Public License as published by the Free Software Foundation; either version
    2 of the License, or (at your option) any later version.
    When redistributing modified versions of this source code it is recommended
    that that this disclaimer and the above coder's names are included in the
    modified code.

Espero que seja útil.

Daniel Padovani

  



Esconder código-fonte

#!/bin/bash
###############################################################################################################
#Objetivo: SCRIPT DE BACKUP UTILIZANDO RSYNC COM ENVIO DO LOG E INFORMATIVO VIA EMAIL                         #
#                                                                                                             #
#Desenvolvido por: Netlider Tecnologia - Daniel Padovani          www.netlider.com.br                         #
#Data: 11 de Março de 2013                                                                                    #
#                                                                                                             #
###############################################################################################################
###############################################################################################################
####
###
##             VARIAVEIS DO USUARIO
#
[email protected]
[email protected]
SERVIDOR_SMTP=servidorsmtp.com.br
SERVIDOR_SMTP_USUARIO=nome_usuario_smtp
SERVIDOR_SMTP_SENHA=senha_usuario_smtp
#
##
###
####
###############################################################################################################
####
###
##             VARIAVEIS DO BACKUP
#
LOCAL_DE="/root/teste/dir1/"
LOCAL_PARA="/root/teste/dir2/"
DIR_LOG="/root/teste/";
#
##
###
####
###############################################################################################################
#######!!!!!!!!!!!!!!ATENCAO NAO ALTERE NADA ABAIXO SEM SABER O QUE ESTA FAZENDO!!!!!!!!!!!!!!!!!!!!!##########
ARQUIVO_LOG=`date +%d%m%Y%k%M%S`;
ARGUMENTO_RSYNC="-ravz --delete"
#
##
###
#######!!!!!!!!!!!!!!ATENCAO NAO ALTERE NADA ABAIXO!!!!!!!!!!!!!!!!!!!!!##########
###
##
#
DATA=`date +%d%m%Y%k%M%S`;
SERVIDOR=`hostname`;
/usr/bin/rsync $ARGUMENTO_RSYNC $LOCAL_DE $LOCAL_PARA > $DIR_LOG$ARQUIVO_LOG".log"
##
/usr/local/bin/sendEmail -f $EMAIL_DE -t $EMAIL_PARA -s $SERVIDOR_SMTP -xu $SERVIDOR_SMTP_USUARIO -xp $SERVIDOR_SMTP_SENHA -u "Backup $SERVIDOR executado em $DATA" -a $DIR_LOG$ARQUIVO_LOG".log" -m "Verifique se o backup foi executado corretamente, log em anexo, execute sempre um restore para testar." >> $DIR_LOG$ARQUIVO_LOG".log"
###FIM

Scripts recomendados

Script de backup Zabbix

Replicação de arquivos

Script de backup dos hosts do Zabbix

Fazendo backup e compactando

Backup do PostgreSQL 8.3 e aviso por e-mail


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner
Linux banner
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts