terça-feira, 27 de setembro de 2011

Backup agendado e envio por e-mail no Mikrotik. / Scheduled backup and sending email in Mikrotik.

Neste tutorial, você vai aprender como configurar o seu servidor Mikrotik para que ele faça o backup automático e logo após envie pra você por e-mail. Para isso, você precisa dos seguintes pré-requisitos:
In this tutorial you will learn how to configure your server Mikrotik for it to do automatic backup and soon after to send you by e-mail. For this you need the followingprerequisites:
  1. Saber qual é o IP do servidor SMTP que você vai usar para enviar o e-mail;
  2. Ter um usuário e senha válidos desse servidor SMTP.
  1. Know what the IP of the SMTP server you will use to send e-mail;
  2. Have a valid username and password of SMTP server.
Vamos começar.
Let's start

1. Primeiro, vamos criar um script para criar o backup do seu servidor. Clique em SYSTEM e depois em SCRIPT.
1. First, let's create a script to create the backup of your server. Click System and thenSCRIPT.


2. Na aba SCRIPT, clique no botão +. No campo NAME, coloque o nome qualquer para esse script. No campo POLICY, deixe todas as opções marcadas. No campo SOURCE, coloque o comando abaixo e depois clique em OK:
2. In the Script tab, click the + button. In the Name field, put any name for this script.POLICY In the field, leave all options checked. In the SOURCE field, place the commandbelow and then click OK:

/system backup save name=o nome que quiser dar ao backup
/system backup save name=the name you want to give backup


3. Agora, vamos criar o script que vai enviar o e-mail para você. Na aba SCRIPT, clique no botão +. No campo NAME, coloque um nome qualquer para esse script. No campo POLICY, deixe todas as opções marcadas. No campo SOURCE, coloque o comando abaixo e depois clique em OK:
3. Now, let's create the script that will send the email to you. In the Script tab, click the + button. In the Name field, enter any name for this script. POLICY In the field, leave alloptions checked. In the SOURCE field, place the command below and then click OK:

/tool e-mail send file=(o nome que você deu ao script do backup criado no passo anterior seguido de .backup) to=(seu e-mail) body=(o que vai está escrito no corpo do e-mail entre "") subject=(o assunto do e-mail)
/tool e-mail send file=(the name you gave the script the backup created in the previous step, followed by .backup) to=(your e-mail) body=(what will is written in the body of the e-mail between "") subject=(the subject of the e-mail)


4. Agora, vamos configurar seu servidor Mikrotik com os dados do seu servidor SMTP para que ele envie os e-mails. Clique em TOOLS e depois em EMAIL.
4. Now we will configure your server with the data Mikrotik of your SMTP server so that it sends e-mails. Click TOOLS and then EMAIL.


5. No campo SERVER, coloque o IP do servidor SMTP que você vai usar. No campo PORT, coloque a porta 25. No campo FROM, coloque um usuário válido desse servidor SMTP que você usou entre < >. No campo USER, repita esse usuário válido sem < >. No campo PASSWORD, coloque a senha válida desse usuário que você utilizou. Agora clique em OK
5. In the Server field, put the IP of the SMTP server you will use. In the Port field, enter port 25. In the FROM field, put a valid user of the SMTP server that you used the <>. In the field USER, repeat this without valid user <>. In the Password field, enter the passwordvalid for that user that you used. Now click OK


6. Antes de fazer o agendamento dos scripts e, assim, torná-los automáticos, vamos testar se tudo está funcionando. Clique novamente em SYSTEM e depois em SCRIPT. Selecione o script que cria o backup e depois clique no botão RUN SCRIPT. Agora clique no botão FILES no menu de botões e certifique que o backup que você criou está lá. Se não está, volte para o início desse tutorial. Se está, volte a janela de scripts, selecione o script que envia o backup e clique em RUN SCRIPT. Agora verifique em sua caixa de e-mail se o seu backup chegou em anexo. Se não chegou, clique no botão LOG no menu de botões e verifique qual erro aconteceu no envio do e-mail.
6. Before making the scheduling of scripts and thus make them automatic, test that everything is working. Click again and then SYSTEM SCRIPT. Select the script thatcreates the backup and then click on RUN SCRIPT. Now click the FILES menu buttonsand make sure the backup that you created is there. If not, go back to the beginning of this tutorial. If you re-scripts window, select the script that sends the backup and click Run Script. Now check box in your e-mail if your backup arrived attached. If not here, click theLOG menu buttons and see what error occurred in sending the email.

7. Agora, se deu tudo certo, vamos programas para que o backup seja realizado e enviado automaticamente. Clique no botão SYSTEM e depois em SCHEDULER.
7. Now, if everything went right, let's programs for the backup is done and sent automatically. Click the button and then SYSTEM SCHEDULER.


8. Vamos criar o agendamento para executar o script do backup. Clique no botão +. No campo NAME, coloque o nome que quiser para esse agendamento. No campo START DATE, coloque quando esse agendamento deve começar. No campo START TIME, coloque que horas ele deve executar. No campo INTERVAL, coloque de quanto em quanto tempo esse agendamento deve ser executado. No meu caso, ele executa de sete em sete dias. No campo ON EVENT, coloque o mesmo nome, exatamente igual (com letras maiúsculas e minúsculas), do que você colocou no script para realizar o backup. No campo POLICY, deixe tudo marcado e clique em OK.
8. Let's create the schedule to run the backup script. Click the + button. In the Name field,enter the name you want for this schedule. In the START DATE field, set when theschedule should start. In the START TIME field, put what time it should run. In the Interval field, set how often to this schedule should run. In my case, it runs every seven days.EVENT ON the field, put the same name, exactly the same (with uppercase andlowercase), than you put in the script to perform the backup. POLICY In the field, leave everything checked and click OK.


9. Agora, vamos criar o agendamento para enviar o e-mail com o backup para você. Clique no botão +. No campo NAME, coloque o nome que quiser para esse agendamento. No campo START DATE, coloque quando esse agendamento deve começar (naturalmente, deve começar no mesmo dia que o agendamento do backup). No campo START TIME, coloque que horas ele deve executar (sugiro colocar cinco minutos após a hora que foi configurada no agendamento do backup). No campo INTERVAL, coloque de quanto em quanto tempo esse agendamento deve ser executado (sugiro o mesmo intervalo que o agendamento do backup). No meu caso, ele executa de sete em sete dias. No campo ON EVENT, coloque o mesmo nome, exatamente igual (com letras maiúsculas e minúsculas), do que você colocou no script para realizar o envio do e-mail. No campo POLICY, deixe tudo marcado e clique em OK.
9. Now, create the schedule for sending the e-mail with the backup for you. Click the + button. In the Name field, enter the name you want for this schedule. In the START DATEfield, place to start when the schedule (of course, must begin the same day as the backup schedule). In the START TIME field, put what time it should run (I suggest putting five minutes after the hour that was set up in the backup schedule). In the Interval field, set how often the schedule is to run this (I suggest the same range as the backup schedule). In my case, it runs every seven days. EVENT ON the field, put the same name, exactly the same (with uppercase and lowercase), than you put in the script to make sending e-mail.POLICY In the field, leave everything checked and click OK.


Pronto. Seu backup está configurado para executar automaticamente e ser enviado para você por e-mail.
Ready. Your backup is configured to run automatically and be sent to you via e-mail.

7 comentários:

  1. Não funciona na versão 5.18 do mk. Tens a solução?

    ResponderExcluir
    Respostas
    1. Seta as seguintes configurações pelo terminal:

      tool e-mail set address=173.194.77.108
      tool e-mail set port=587
      tool e-mail set from=usuario@gmail.com
      tool e-mail set user=usuario
      tool e-mail set password=sua_senha

      Crie o seguinte script:

      Para gerar o backup (sources):

      /system backup save name=nome_backup

      *********************************************

      Para enviar:
      /tool e-mail send to=email_de_destino subject="assunto" body="Oi! Eu sou o servidor tal! Em anexo estou enviando o meu backup automatizado... :)" tls=yes file=nome_backup

      Excluir
  2. tem algum que funcione no RB 450 g obrigado Romulo
    se puder me enviar: romulorocha@gmail.com

    ResponderExcluir
  3. nao consigo enviar com versao 5.20 da erro send email

    ResponderExcluir
  4. Não estou conseguindo envia com a versão 5.16 do Mikrotik alguem tem alguma dica, oliveiraejo@hotmail.com

    ResponderExcluir
  5. como enviar todos os backups de uma só vez?

    ResponderExcluir