backup script for newbie

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?

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.

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.

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. :smiley:

Thanks chemambo,

I was able to make it work :slight_smile: . 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.

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! :slight_smile:

On script options check “sensitive” box
Tested on ROS 5.8

Hi…

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

thansk.

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 :smiley: