Community discussions

MikroTik App
 
whiskeyman7
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 86
Joined: Tue Jul 30, 2013 8:30 pm
Location: Costa Rica

Automated Script backup Email Error

Sat Dec 06, 2014 6:04 pm

Hello Everyone,

Router: RB450G os6.22

I have a script for creating and sending a .rsc and .backup files automatically but an error occurs. This script is working on other routers but this is the first time this script has been used on a duel wan router.

09:39:11 e-mail,debug recv: 220 BLU437-SMTP96.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Sat, 6 Dec 2014 07:39:11 -0800
09:39:11 e-mail,debug send EHLO [192.168.4.100]
09:39:11 e-mail,debug recv: 250-BLU437-SMTP96.smtp.hotmail.com Hello [190.151.134.250]
09:39:11 e-mail,debug recv: 250-TURN
09:39:11 e-mail,debug recv: 250-SIZE 41943040
09:39:11 e-mail,debug recv: 250-ETRN
09:39:11 e-mail,debug recv: 250-PIPELINING
09:39:11 e-mail,debug recv: 250-DSN
09:39:11 e-mail,debug recv: 250-ENHANCEDSTATUSCODES
09:39:11 e-mail,debug recv: 250-8bitmime
09:39:11 e-mail,debug recv: 250-BINARYMIME
09:39:11 e-mail,debug recv: 250-CHUNKING
09:39:11 e-mail,debug recv: 250-VRFY
09:39:11 e-mail,debug recv: 250-TLS
09:39:11 e-mail,debug recv: 250-STARTTLS
09:39:11 e-mail,debug recv: 250 OK
09:39:11 e-mail,debug send STARTTLS
09:39:11 e-mail,debug recv: 220 2.0.0 SMTP server ready
09:39:12 e-mail,debug send EHLO [192.168.4.100]
09:39:12 e-mail,debug recv: 250-BLU437-SMTP96.smtp.hotmail.com Hello [190.151.134.250]
09:39:12 e-mail,debug recv: 250-TURN
09:39:12 e-mail,debug recv: 250-SIZE 41943040
09:39:12 e-mail,debug recv: 250-ETRN
09:39:12 e-mail,debug recv: 250-PIPELINING
09:39:12 e-mail,debug recv: 250-DSN
09:39:12 e-mail,debug recv: 250-ENHANCEDSTATUSCODES
09:39:12 e-mail,debug recv: 250-8bitmime
09:39:12 e-mail,debug recv: 250-BINARYMIME
09:39:12 e-mail,debug recv: 250-CHUNKING
09:39:12 e-mail,debug recv: 250-VRFY
09:39:12 e-mail,debug recv: 250-AUTH LOGIN PLAIN XOAUTH2
09:39:12 e-mail,debug recv: 250 OK
09:39:12 e-mail,debug send AUTH PLAIN AHJqc2F1ZXJfNTRAaG90bWFpbC5jb20Ad2gxc2szeQ==
09:39:13 e-mail,debug recv: 235 2.7.0 Authentication succeeded
09:39:13 e-mail,debug send MAIL FROM: <my@router.com>
09:39:13 e-mail,debug recv: 250 2.1.0 my@router.com....Sender OK
09:39:13 e-mail,debug send RCPT TO: <email@hotmail.com>
09:39:13 e-mail,debug recv: 250 2.1.5 email@hotmail.com
09:39:13 e-mail,debug send DATA
09:39:13 e-mail,debug recv: 354 Start mail input; end with <CRLF>.<CRLF>
09:39:16 e-mail,debug recv: 220 BLU437-SMTP96.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Sat, 6 Dec 2014 07:39:16 -0800
09:39:16 e-mail,debug send EHLO [192.168.4.100]
09:39:16 e-mail,debug recv: 250-BLU437-SMTP96.smtp.hotmail.com Hello [190.151.134.250]
09:39:16 e-mail,debug recv: 250-TURN
09:39:16 e-mail,debug recv: 250-SIZE 41943040
09:39:16 e-mail,debug recv: 250-ETRN
09:39:16 e-mail,debug recv: 250-PIPELINING
09:39:16 e-mail,debug recv: 250-DSN
09:39:16 e-mail,debug recv: 250-ENHANCEDSTATUSCODES
09:39:16 e-mail,debug recv: 250-8bitmime
09:39:16 e-mail,debug recv: 250-BINARYMIME
09:39:16 e-mail,debug recv: 250-CHUNKING
09:39:16 e-mail,debug recv: 250-VRFY
09:39:16 e-mail,debug recv: 250-TLS
09:39:16 e-mail,debug recv: 250-STARTTLS
09:39:16 e-mail,debug recv: 250 OK
09:39:16 e-mail,debug send STARTTLS
09:39:17 e-mail,debug recv: 220 2.0.0 SMTP server ready
09:39:17 e-mail,debug send EHLO [192.168.4.100]
09:39:17 e-mail,debug recv: 250-BLU437-SMTP96.smtp.hotmail.com Hello [190.151.134.250]
09:39:17 e-mail,debug recv: 250-TURN
09:39:17 e-mail,debug recv: 250-SIZE 41943040
09:39:17 e-mail,debug recv: 250-ETRN
09:39:17 e-mail,debug recv: 250-PIPELINING
09:39:17 e-mail,debug recv: 250-DSN
09:39:17 e-mail,debug recv: 250-ENHANCEDSTATUSCODES
09:39:17 e-mail,debug recv: 250-8bitmime
09:39:17 e-mail,debug recv: 250-BINARYMIME
09:39:17 e-mail,debug recv: 250-CHUNKING
09:39:17 e-mail,debug recv: 250-VRFY
09:39:17 e-mail,debug recv: 250-AUTH LOGIN PLAIN XOAUTH2
09:39:17 e-mail,debug recv: 250 OK
09:39:17 e-mail,debug send AUTH PLAIN AHJqc2F1ZXJfNTRAaG90bWFpbC5jb20Ad2gxc2szeQ==
09:39:18 e-mail,debug recv: 235 2.7.0 Authentication succeeded
09:39:18 e-mail,debug send MAIL FROM: <my@router.com>
09:39:18 e-mail,debug recv: 250 2.1.0 my@router.com....Sender OK
09:39:18 e-mail,debug send RCPT TO: <email@hotmail.com>
09:39:18 e-mail,debug recv: 250 2.1.5 email@hotmail.com
09:39:18 e-mail,debug send DATA
09:39:18 e-mail,debug recv: 354 Start mail input; end with <CRLF>.<CRLF>
09:40:11 system,e-mail,error Error sending e-mail <DavesRouter_Automated_Backup>: abnormal termination (timeout)
09:40:16 system,e-mail,error Error sending e-mail <DavesRouter_Automated_Backup>: abnormal termination (timeout)



Here is the Backup Script
:log info "Automated Backup Protocol Started"
:delay 2s
;log info "Creating Backup Files. This may take several minutes."
:local sysname [/system identity get name]
:local textfilename
:local backupfilename
:local time [/system clock get time]
:local date [/system clock get date]
:local newdate "";
:for i from=0 to=([:len $date]-1) do={ :local tmp [:pick $date $i];
:if ($tmp !="/") do={ :set newdate "$newdate$tmp" }
:if ($tmp ="/") do={}
}
:if ([:find $sysname " "] !=0) do={
:local name $sysname;
:local newname "";
:for i from=0 to=([:len $name]-1) do={ :local tmp [:pick $name $i];
:if ($tmp !=" ") do={ :set newname "$newname$tmp" }
:if ($tmp =" ") do={ :set newname "$newname_" }
}
:set sysname $newname;
}
:set textfilename ($"newdate" . "-" . $"sysname" . ".rsc")
:set backupfilename ($"newdate" . "-" . $"sysname" . ".backup")
:execute [/export file=$"textfilename"]
:execute [/system backup save name=$"backupfilename"]
:delay 5s
:log info "Sending Backup Files"
/tool e-mail send to="email@hotmail.com" subject=([/system identity get name] . \
"_Automated_Backup") from="my@router.com" file=($"newdate" . "-" . $"sysname" . ".rsc") \
server=[:resolve "smtp.live.com"] start-tls=yes port=587 \
password=password user=email@hotmail.com
:delay 5s
/tool e-mail send to="email@hotmail.com" subject=([/system identity get name] . \
"_Automated_Backup") from="my@router.com" file=($"newdate" . "-" . $"sysname" . ".backup")  \
server=[:resolve "smtp.live.com"] start-tls=yes port=587 \
password=password user=email@hotmail.com
:delay 5s
:log info "Sending Completed"
:delay 5s
:log info "Removing Backup files from router file list"
/file remove ($"newdate" . "-" . $"sysname" . ".rsc")
/file remove ($"newdate" . "-" . $"sysname" . ".backup")
:log info "Automated Backup Protocol Completed"
Any Ideas?
Thank you in advance.
 
whiskeyman7
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 86
Joined: Tue Jul 30, 2013 8:30 pm
Location: Costa Rica

Re: Automated Script backup Email Error

Tue Dec 09, 2014 10:51 pm

Any help would be greatly appreciated.

Thanks
 
whiskeyman7
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 86
Joined: Tue Jul 30, 2013 8:30 pm
Location: Costa Rica

Re: Automated Script backup Email Error

Sun Dec 14, 2014 5:27 am

Someone's gotta see something???

I would like to see if the emails could be sent through the second ISP. So how can I re-direct the router email through WAN2?

Thanks
 
whiskeyman7
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 86
Joined: Tue Jul 30, 2013 8:30 pm
Location: Costa Rica

Re: Automated Script backup Email Error

Tue Dec 16, 2014 5:29 am

The backup email works no problem through WAN2.

Just needed to add this rule to my mangle.
add action=mark-routing chain=output comment=\
    "Route Router Email Backup Through WAN2" new-routing-mark=WAN2_rout port=\
    587 protocol=tcp
 
User avatar
fengyuclub
Member Candidate
Member Candidate
Posts: 104
Joined: Mon Dec 09, 2013 8:50 am

Re: Automated Script backup Email Error

Tue Jan 12, 2016 4:52 am

Nice! Use your script successfully sent mail

Who is online

Users browsing this forum: No registered users and 24 guests