Community discussions

MikroTik App
 
mbghost
just joined
Topic Author
Posts: 14
Joined: Wed Dec 08, 2021 4:10 pm

Script don't work

Wed Sep 14, 2022 3:39 pm

Hello, I can't run this script, it worked a week ago, and I didn't change anything connected with him ,if write only
:log info "Starting Backup Script...";
it show in Log, but if I run all script, it's do not show anything in Log
{

:log info "Starting Backup Script...";

:local sysname [/system identity get name];

:local sysver [/system package get system version];

:log info "Flushing DNS cache...";

/ip dns cache flush;

:delay 2;

:log info "Deleting last Backups...";

:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] \

"$sysname-backup-"]]!="nil") do={/file remove $i}};

:delay 2;

:local smtpserv [:resolve "smtp.gmail.com"];

:local Eaccount mail@mail.com;

:local EaccountTo  mail@mail.com;

:local pass password;

:local backupfile ("$sysname-backup-" . \

[:pick [/system clock get date] 7 11] . [:pick [/system \

clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".backup");

:log info "Creating new Full Backup file...";

/system backup save name=$backupfile;

:delay 2;

:log info "Sending Full Backup file via E-mail...";

/tool e-mail send from="<$Eaccount>" to=$Eaccount server=$smtpserv \

port=587 user=$Eaccount password=$pass start-tls=yes file=$backupfile \

subject=("$sysname Full Backup (" . [/system clock get date] . ")") \

body=("$sysname full Backup file see in attachment.\nRouterOS version: \

$sysver\nTime and Date stamp: " . [/system clock get time] . " " . \

[/system clock get date]);

:delay 5;

:local exportfile ("$sysname-backup-" . \

[:pick [/system clock get date] 7 11] . [:pick [/system \

clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc");

:log info "Creating new Setup Script file...";

/export verbose file=$exportfile;

:delay 2;

:log info "Sending Setup Script file via E-mail...";

/tool e-mail send from="<$Eaccount>" to=$Eaccount server=$smtpserv \

port=587 user=$Eaccount password=$pass start-tls=yes file=$exportfile \

subject=("$sysname Setup Script Backup (" . [/system clock get date] . \

")") body=("$sysname Setup Script file see in attachment.\nRouterOS \

version: $sysver\nTime and Date stamp: " . [/system clock get time] . " \

" . [/system clock get date]);

:delay 5;

:log info "All System Backups emailed successfully.\nBackuping completed.";

}
and Email if working correct, I already check it
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script don't work

Wed Sep 14, 2022 8:43 pm

For example, did you forget that you upgraded from v6 to v7?
 
mbghost
just joined
Topic Author
Posts: 14
Joined: Wed Dec 08, 2021 4:10 pm

Re: Script don't work

Thu Sep 15, 2022 7:18 am

For example, did you forget that you upgraded from v6 to v7?
It start do not work before upgraded
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script don't work  [SOLVED]

Thu Sep 15, 2022 8:43 am

You do not need { in start of script, same not need } at end of script.
You also do not need ; at end of each line. Only while separate various command on same line. (But do not do that, messy)

This script do work.
viewtopic.php?t=183631
 
mbghost
just joined
Topic Author
Posts: 14
Joined: Wed Dec 08, 2021 4:10 pm

Re: Script don't work

Thu Sep 15, 2022 9:46 am

You do not need { in start of script, same not need } at end of script.
You also do not need ; at end of each line. Only while separate various command on same line. (But do not do that, messy)

This script do work.
viewtopic.php?t=183631
Got it, I'll try by the script))
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script don't work

Thu Sep 15, 2022 11:05 am

For example, did you forget that you upgraded from v6 to v7?
It start do not work before upgraded
It was pretty easy to figure out what you did ...
The script (ignoring syntax horrors) cannot work on any (actual or previous) v7 version...
You probably remember badly, it's since you upgraded to v7 that it doesn't work.
On v6 it's quite unlikely it won't work, but I may have had an oversight.
 
mbghost
just joined
Topic Author
Posts: 14
Joined: Wed Dec 08, 2021 4:10 pm

Re: Script don't work

Fri Sep 16, 2022 11:45 am

Thank you so much))

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 49 guests