Community discussions

MikroTik App
 
User avatar
radiosn00p
just joined
Topic Author
Posts: 10
Joined: Sat Feb 04, 2006 12:22 am

backup script for newbie

Sat Aug 07, 2010 3:06 am

HELP!! I'm trying to resolve a scripting issue. If I use the following from a terminal session it works every time:

/system backup save name=([/system identity get name]); /tool e-mail send to= "me@me.com" subject=([/system identity get name] . " Backup") file=([/system identity get name] . ".backup")

But if I create a script with the exact information as above I get the following error in the log:

Aug/06/2010 19:56:00 system e-mail error Error sending e-mail: error handling file

Can some one please explain why?
 
adrianatkins
Long time Member
Long time Member
Posts: 556
Joined: Wed Sep 05, 2007 10:34 am
Location: Spain
Contact:

Re: backup script for newbie

Sat Aug 07, 2010 3:13 am

Check your Email settings under tool->email, and maybe add server=MySMTPServer to the /tool email line.

Beware of line breaks in youe scripts too.
Don't forget to give me at least a tenner a month, every month
 
User avatar
radiosn00p
just joined
Topic Author
Posts: 10
Joined: Sat Feb 04, 2006 12:22 am

Re: backup script for newbie

Mon Aug 09, 2010 3:17 pm

Check your Email settings under tool->email, and maybe add server=MySMTPServer to the /tool email line.

Beware of line breaks in youe scripts too.
Thanks for your insight. All those settings are correct and I have tried everything you suggested before posting this thread.

Oddly enough the e-mail function works as I stated, when using the posted script commands from the command line, but not from the script function. Also I have one additional script that works fine e-mail wise, the difference is that it is a exported backup script and I believe it has to do with the file extension descriptor size. A backup file is as follows 'file name'.backup whereas a script backup or export is 'file name'.rsc I just thought that more people would have run into this issue. Will see if Mikrotik support has a reason for the failure.
 
kirshteins
MikroTik Support
MikroTik Support
Posts: 592
Joined: Tue Dec 02, 2008 10:55 am

Re: backup script for newbie

Mon Aug 09, 2010 3:44 pm

Check policies of your script. Perhaps backup file is not fully generated before the attempt to send it. Try to add short delay in between generating backup and sending the file.
/system backup save name=([/system identity get name]);
/delay delay-time=5s ;
/tool e-mail send to= "me@me.com" subject=([/system identity get name] . " Backup") file=([/system identity get name] . ".backup")
 
User avatar
radiosn00p
just joined
Topic Author
Posts: 10
Joined: Sat Feb 04, 2006 12:22 am

Re: backup script for newbie

Mon Aug 09, 2010 9:47 pm

Check policies of your script. Perhaps backup file is not fully generated before the attempt to send it. Try to add short delay in between generating backup and sending the file.
/system backup save name=([/system identity get name]);
/delay delay-time=5s ;
/tool e-mail send to= "me@me.com" subject=([/system identity get name] . " Backup") file=([/system identity get name] . ".backup")
Thanks, did that and had no effect. I wonder if it has to do with the length of the extension because I use the basic same script for generating a backup script.

/export file=([/system identity get name]); /tool e-mail send to= "me@me.com" subject=([/system identity get name] . " rsc") file=([/system identity get name] . ".rsc")

This script runs with the same permissions and never has the problem that the backup script does. This one is created about 1 min after the backup and e-mailed about one minute after the backup attempts to. This never!!! fails. The other always!!! fails. the only difference is the length of the extension (3 characters vs. 6 characters). I am truly surprised no one else has this issue. I have tried the sample scripts on the wiki and the same issue. Running routeros 3.30 & 4.x. Prior to upgrading to 3.30 to resolve some other issues, we ran 3.6 and it always worked fine.
 
chemambo
just joined
Posts: 2
Joined: Thu May 27, 2010 2:11 pm

Re: backup script for newbie

Tue Aug 10, 2010 1:13 pm

hi

I solved this issue on my router board by creating two separate scripts

the first: /system backup save name=([/system identity get name])

then the second script : /tool e-mail send to= "test@test.com" subject=([/system identity get name] . " Backup") file=([/system identity get name] . ".backup")

I then used system scheduler to run the scripts, starting with the backup script and then 5mins later the "send email script.

Hope this works for you. :D
 
User avatar
radiosn00p
just joined
Topic Author
Posts: 10
Joined: Sat Feb 04, 2006 12:22 am

Re: backup script for newbie

Thu Aug 12, 2010 3:41 pm

Thanks chemambo,

I was able to make it work :) . But now I have over 300 devices that need updating. It is not cool to have OS updates destroy previously working scripts and features without maintaining consistency!!

Appreciate your help.
 
Nedialko
just joined
Posts: 7
Joined: Wed Jun 06, 2007 4:37 pm

Re: backup script for newbie

Sat May 26, 2012 9:24 am

I had the same problem. I chose it as given waiting time of 10 seconds to send e-mail. Remember: Creating a file takes time! :-)

On script options check "sensitive" box
Tested on ROS 5.8
 
angboontiong
Forum Guru
Forum Guru
Posts: 1116
Joined: Fri Jan 16, 2009 9:59 am

Re: backup script for newbie

Mon May 28, 2012 6:19 pm

Hi...

how can we send the file to the gmail?
do we need to set the server ip and the port?

thansk.
 
whiskeyman7
Frequent Visitor
Frequent Visitor
Posts: 86
Joined: Tue Jul 30, 2013 8:30 pm
Location: Costa Rica

Re: backup script for newbie

Fri Jul 25, 2014 5:34 am

Here is an example:

:log info "backup beginning"
:global backupfile ([/system identity get name] . "-" . [/system clock get time])
/system backup save name=$backupfile
:log info "backup pausing for 10s"
:delay 10s
:log info "backup being emailed"
/tool e-mail send to="youremail@gmail.com" subject=([/system identity get name] . \
" Backup") from=myrouter file=$backupfile server=[:resolve "smtp.gmail.com"] start-tls=yes port=587\
password=password user=youremail@gmail.com
:log info "backup finished"

Hope this helps :D

Who is online

Users browsing this forum: No registered users and 21 guests