I have this script which was working in the past, but seems to no longer work. It is supposed to create a backup and then email it, but it doesn’t seem to send the emails. Can anyone see the problem? (passwords removed)
/tool e-mail
set address=email-smtp.us-west-2.amazonaws.com from=mikrotik@xxx.com password=xxx \
port=587 start-tls=tls-only user=xxxx
/system scheduler
add interval=1w name="Upgrade Router" on-event="/system package update set chann\
el=stable; /system package update check-for-updates; /system package update\
\_download; /system reboot;" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=jan/01/2018 start-time=04:00:00
add interval=24h name=Backup on-event=":local emailAddress \"mikrotik.o8507@xxxx.c\
om\"\r\
\n:log info \"BACKUP STARTING NOW\"\r\
\n:global backupfile ([/system identity get name] . \"-\" . [/system clock g\
et time])\r\
\n/system backup save name=\$backupfile\r\
\n:log info \"BACKUP FILE SAVED, SENDING EMAIL IN 2 SECONDS\"\r\
\n:delay 2s\r\
\n/tool e-mail send to=\"\$emailAddress\" subject=([/system identity get nam\
e] . \" Backup \" . [/system clock get date] . \" \" . [/system clock get ti\
me]) file=\$backupfile\r\
\n:delay 15s\r\
\n:log info \"BACKUP EMAIL SENT, REMOVING BACKUP FILE\"\r\
\n/file remove \$backupfile\r\
\n:log info \"BACKUP FINISHED\"" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=apr/05/2019 start-time=15:25:22
Post the the script as copy past from the gui. Its hard to understand and debug script like this.
Never ever auto upgrade your router. Only upgrade if:
..a. you need to upgrade. (new function, serious bug fix etc)
..b. read the forum over and over
..c. wait at least some week after a new release before upgrade.
..d. the read forum again to see if there are any show stoppers
..e. upgrade on an equal router with same software as prod ruter. test if all works fine
..f. make a backup
..g. then you may upgrade if you need.
Example on script posting.
:local emailAddress "mikrotik.o8507@xxxx.com"
:log info "BACKUP STARTING NOW"
:global backupfile ([/system identity get name] . "-" . [/system clock get time])
/system backup save name=$backupfile
:log info "BACKUP FILE SAVED, SENDING EMAIL IN 2 SECONDS"
:delay 2s
/tool e-mail send to="$emailAddress" subject=([/system identity get name] . " Backup " . [/system clock get date] . " " . [/system clock get time]) file=$backupfile
:delay 15s
:log info "BACKUP EMAIL SENT, REMOVING BACKUP FILE"
/file remove $backupfile
:log info "BACKUP FINISHED"
The gmail script seems to work well, just what I need. Do you have a version that can be pasted in the terminal that automatically creates the scheduler entry?
I suggest you to change the format from
DDMMYYYY-HHMMSS
to
YYYYMMDD-HHMMSS
On this way the files are sortable for names…
(yes, I know also are sortable for dates…)