Community discussions

MikroTik App
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Scripts stops working after upgrade ROS

Mon Jun 28, 2021 10:39 am

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"
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 12:12 pm

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
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 4:09 pm

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"
Last edited by rextended on Mon Jun 28, 2021 7:17 pm, edited 1 time in total.
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 7:10 pm

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??
Last edited by donsergio on Mon Jun 28, 2021 7:32 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 7:17 pm

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.
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 7:40 pm

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
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 7:45 pm

Try to increase the delay after first mail send from 30 (or 60) to 120 seconds...
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 8:18 pm

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....
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Mon Jun 28, 2021 9:02 pm

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 <prueba> 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....
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scripts stops working after upgrade ROS

Tue Jun 29, 2021 11:14 am

open log,
open files,
do manually one backup

on log appear one line with "error creating backup file" inside?
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Tue Jun 29, 2021 6:40 pm

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...
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scripts stops working after upgrade ROS

Tue Jun 29, 2021 9:06 pm

Surely this make me an headache for just try to imagine what can be wrong...
 
User avatar
donsergio
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Wed Jan 31, 2018 8:35 pm
Location: Spain

Re: Scripts stops working after upgrade ROS

Wed Jun 30, 2021 9:35 am

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 viewtopic.php?t=151953 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....

Who is online

Users browsing this forum: caldo85 and 22 guests