Script de backup remoto por FTP – Mikrotik | AcessoWi-Fi

Script de backup remoto por FTP – Mikrotik

Download PDF

Olá amigos AcessoWi-Fi.com!

 

Para quem precisar de um sistema de backup remoto no mikrotik que envie o backup para um servidor ftp externo ou dentro da própria rede, segue o script.

# Sistema de backup por FTP Externo

# configuração do servidor FTP
:local ftphost “<<FTP IP>>”
:local ftpuser “<<FTP USERNAME>>”
:local ftppassword “<<FTP PASSWORD>>”
:local ftppath “<<FTP PATH>>”

# Define os meses
:local months (“jan”,”feb”,”mar”,”apr”,”may”,”jun”,”jul”,”ago”,”sep”,”oct”,”nov”,”dec”);

# Registro de horário
:local ts [/system clock get time]
:set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])

# Registro de data
:local ds [/system clock get date]

# Converte nome do mes em números
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set mm (“0” . $mm); }
# set $ds to format YYYY-MM-DD
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])

# file name for user manager backup – file name will be UMDB-servername-date-time.umb
:local fname (“/UMDB-“.[/system identity get name].”-“.$ds.”-“.$ts.”.umb”)
# file name for system backup – file name will be UMDB-servername-date-time.backup
:local fname1 (“/UMDB-“.[/system identity get name].”-“.$ds.”-“.$ts.”.backup”)
# file name for config export – file name will be UMDB-servername-date-time.rsc
:local fname2 (“/UMDB-“.[/system identity get name].”-“.$ds.”-“.$ts.”.rsc”)

# backup the data
/tool user-manager database save name=$fname
:log info message=”User manager backup finished (1/3).”;
/system backup save name=$fname1
:log info message=”System backup finished (2/3).”;
/export compact file=$fname2
:log info message=”Config export finished (3/3).”

# upload the user manager backup
:log info message=”Uploading user manager backup (1/3).”
/tool fetch address=”$ftphost” src-path=$fname user=”$ftpuser” mode=ftp password=”$ftppassword” dst-path=”$ftppath/$fname” upload=yes
# upload the system backup
:log info message=”Uploading system backup (2/3).”
/tool fetch address=”$ftphost” src-path=$fname1 user=”$ftpuser” mode=ftp password=”$ftppassword” dst-path=”$ftppath/$fname1″ upload=yes
# upload the config export
:log info message=”Uploading config export (3/3).”
/tool fetch address=”$ftphost” src-path=$fname2 user=”$ftpuser” mode=ftp password=”$ftppassword” dst-path=”$ftppath/$fname2″ upload=yes

# delay time to finish the upload – increase it if your backup file is big
:delay 60s;
# find file name start with UMDB- then remove
:foreach i in=[/file find] do={ :if ([:typeof [:find [/file get $i name] “UMDB-“]]!=”nil”) do={/file remove $i}; }
:log info message=”Configuration backup finished.”;

Não esqueça de fazer um sheduler para rodar o script no intervalo que achar necessário!

 

Espero que tenham gostado… até a próxima.

 


  • Nosso blog te ajuda? Ajude-nos também!

    Se nosso blog tem lhe ajudado, ajude a manter o site no ar!

  • Meu IP

  • IPv4 e IPv6 no mundo

  • Assinar blog por e-mail

    Digite seu endereço de e-mail para assinar este blog e receber notificações de novas publicações por e-mail.

  • Recursos Online

  • Seo wordpress plugin by www.seowizard.org.