Hi, I have several scripts to automate some tasks such as backups…
I updated to ROS v6.47.10 and lot of scripts stops working… here I put one of them… it make a .backup and .rsc files and send to email.
The scripts create the two files, send only the .backup but no send .rsc file… (in others RB with the same script, same ROS update, copied and pasted scripts, sends .rsc but no send .backup)… it´s so strange.
email in /tool email are configured and working
Tried to paste line per line on the terminal and no errors shown…
When send the command to send .rsc the terminal saw that sent but no received on the email account.
if I try :put $backupfile and :put $exportfile I got and out the name of the respective files…
I get the code from any webpage, don´t remember… tried too to enable “Don´t require permissions” with no luck.
###### Configuracion v0.2
#Email destino
:global emaildest "backup@email.com"
#Email desde el que envias. Debe estar configurado en /tools email
:global emailfrom "backup@email.com"
:delay 15s
:log info "## Backup System Start"
:delay 2s
:log info "## Creando Fichero Backup"
:global backupfile ([/system identity get name] . "-" . \
[:pick [/system clock get date] 4 6] . "-" . [:pick [/system clock get date] 0 3] . "-" . [:pick [/system clock get date] 7 11] . "-" . \
[:pick [/system clock get time] 0 8])
/system backup save name=$backupfile
:delay 30s
:log info "## Creando Fichero Export"
:global exportfile ([/system identity get name] . "-" . \
[:pick [/system clock get date] 4 6] . "-" . [:pick [/system clock get date] 0 3] . "-" . [:pick [/system clock get date] 7 11] . "-" . \
[:pick [/system clock get time] 0 8])
/export file=$exportfile
:delay 30s
:log info "## Enviando email con el export"
/tool e-mail send to=$emaildest subject=([/system identity get name] . \
" Export System") from=$emailfrom file=$exportfile
:delay 50s
:log info "## Enviando email con el backup"
/tool e-mail send to=$emaildest subject=([/system identity get name] . \
" Backup System") from=$emailfrom file=$backupfile
:delay 50s
:log info "## Borrando Fichero Backup"
/file rem $backupfile
:delay 2s
:log info "## Borrando Fichero Export"
/file rem $exportfile
:delay 2s
:log info "## Backups terminados y ficheros enviados"
I tried with a hEXs with empty configuration and working fine… who could be the trouble?
Failing in three devices, one RB1100-ahx2, one RB850G and one chr
A gift for you:
:local emailfrom "backup@email.com"
:local emailto "backup@email.com"
:log info "## Backup System Start"
:global mon2num do={ :return ([:find "rexjanfebmaraprmayjunjulagosepoctnovdec" $1 -1] / 3) }
:local data [/system clock get date]
:local time [/system clock get time]
:local monnum [:tostr [$mon2num [:pick [$data] 0 3]]]
:if ([:len $monnum] = 1) do={:set $monnum "0$monnum"}
:local timbro ([:pick [$data] 7 11] . "-$monnum-" . [:pick [$data] 4 6] . "-" . [:pick [$time] 0 8])
:local routername [/system identity get name]
:local filename "$routername-$timbro"
/export file=$filename
:delay 60s
/system backup save dont-encrypt=yes password="" name=$filename
:delay 60s
/tool e-mail send from=$emailfrom to=$emailto subject="$routername Export System" file="$filename.rsc"
:delay 60s
/tool e-mail send from=$emailfrom to=$emailto subject="$routername Backup System" file="$filename.backup"
:delay 60s
/file rem [find where name~"$filename"]
:log info "## Backup System End"
Hi, thanks a lot for your code, it´s a lot clean than mine, but… but… doesn´t work like mine… send .rsc file only and “script stop”… not continue…
I copy paste and change only emailfrom and emailto
It could be a bug of this version??
Sorry, I have commtted an error inside: is “backup” the right extension, not “bak”
Please edit your previos post and remove quote, and on general use, use quote only when really need, must be used “post reply” for… reply.
I have modified my previous post, try again please.
Sorry, I´ll use Post Reply always…
I tried before my last answer to change .bak to .backup and trouble still, the script finish but on the email account not receive the .backup email…
I tried with three different emails accounts… one with own domain, with hotmail and gmail… no luck
My script stop working after upgrade system… same trouble with your script
Try to increase the delay after first mail send from 30 (or 60) to 120 seconds…
Nothing… same issue…
In another RB tested and working fine… same ROS
In three production RBs working bad… or send .rsc or send .backup…
Could be another script interfering this? I think no…
I made some tests sending email from command line…
I tested if could be a file size trouble (the .backup files are 287Kb)… tried with autosupout.rif (620Kb) and I received well the .rif file… not file size trouble.
Tried sending .txt files and received correct, tried .html file and received correct.
Tried to send and auto-before-reset.backup file that I has and send correctly
Tried to make a .backup from command line and send by email and not send…
Tried several names for the .backup… create backup name adding .backup at end and without adding .backup at end
In RB log say “sent to: email@email.com” each time I send an email (even if receive or not)
Now I´m in a stable release v6.48.3… release issue I think not are…
Tried to reboot the routerboard…
open log,
open files,
do manually one backup
on log appear one line with “error creating backup file” inside?
I opened logs, no error…
I create the backup in terminal and send with commands and no error on log, no error on terminal but not send, check my last message… the auto-backup-after-reset.backup sent but the others backups no…
Finally I create on one server that I has on datacenter a SFTP server and with an script upload every day the backups, because I can´t find what is the error…
Surely this make me an headache for just try to imagine what can be wrong…
But I think could be a “firmware corruption or firmware bug”… the three RBs are working fine… but the backup2mail script and the LogFilter script http://forum.mikrotik.com/t/monitor-mikrotik-log-by-telegram/133039/1 stop working on all… and I don´t know why they works on other test RouterBoard and no in the three RouterBoard production… They stop working until I upgrade to latest LongTerm version… Now I´m in latest Stable…
The most strange is… no error in log…
I think I leave this as is…